Giter Club home page Giter Club logo

Comments (7)

dbanck avatar dbanck commented on July 17, 2024 3

The underlying issue here is, that { for ... } will result in an object, but the for_each meta-argument accepts a map or a set of strings. Passing objects to for_each is still supported for backwards compatibility reasons, but should generally be avoided.

A workaround is to wrap the expression in a tomap call:

resource "local_file" "foobar" {
  for_each = tomap({ for i in var.foobar : i.name => i })

  content  = each.value.name
  filename = "${path.module}/${each.value.name}.txt"
}

This will get rid of the error and fix the completion and go to definition for var.foobar.

The validation error here is still worth fixing though, because it is a valid Terraform configuration. In an ideal world, we would raise a warning instead and allow you to apply a quickfix.

from vscode-terraform.

scott-doyland-burrows avatar scott-doyland-burrows commented on July 17, 2024 3

It doesn't always pick up on that as an error. I have that type of code all over the place, and not all show as errors.

image

image

image

I disagree that this should even raise a warning. If terraform validate allows it then so should the vscode extension. In my opinion there shouldn't be a difference between the two.

from vscode-terraform.

dbanck avatar dbanck commented on July 17, 2024 1

We just released a new version 2.29.5. This fixes the reported bug. The update should appear automatically in VS Code.

Thank you for the report @pawwe


In case you experience any different validation related bug, please do let us know through a new issue.

from vscode-terraform.

KazuSh1geru avatar KazuSh1geru commented on July 17, 2024

I'm the same.

from vscode-terraform.

dbanck avatar dbanck commented on July 17, 2024

Thanks for the report! I can reproduce the issue with the snippet you provided.

from vscode-terraform.

pawwe avatar pawwe commented on July 17, 2024

That makes sense. Thanks for looking into it!

from vscode-terraform.

github-actions avatar github-actions commented on July 17, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

from vscode-terraform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.