Comments (7)
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.
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.
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.
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.
I'm the same.
from vscode-terraform.
Thanks for the report! I can reproduce the issue with the snippet you provided.
from vscode-terraform.
That makes sense. Thanks for looking into it!
from vscode-terraform.
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)
- No declaration found for nested object in list HOT 3
- Variable falsely marked as not declared in for_each block. HOT 2
- Completions: Recover partially typed provider defined functions after the first colon has been typed HOT 2
- false "No Declaration found" HOT 4
- Terraform Stacks Editor Support
- Format does not align = signs when type is multiline array HOT 2
- Vscode Language Server is preloading wrong provider version - intellisense then not working HOT 12
- Document is Open - Ignoring Event HOT 3
- Extension report problems in `~/.vscode-server/data/User/History/` HOT 3
- "no declaration found" for heteregeneous list HOT 2
- TFC Login Test
- Terraform Auto complete Not working HOT 7
- vscode always complains `This module is not yet installed` error in submodules HOT 1
- Extension shows a deprecation for an attribute but not the reason HOT 2
- Terraform intellisense is not showing when using module with github as the source HOT 2
- Completions for variables include the var. (unless you don't type the dot) HOT 3
- Syntax Highlighting Breaks If a Function is Split Over Multiple Lines When in String Interpolation HOT 1
- "tags" not expected in `aws_budgets_budget` HOT 3
- Error in transit_encryption_mode attribute on AWS aws_elasticache_replication_group Resource HOT 3
- "Unexpected attribute: An attribute named "private_endpoint_network_policies" is not expected here" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-terraform.