-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using "computed" values in maps not possible #7241
Comments
Hi @Alars-ALIT! I can reproduce this - thanks for the concise example. I'll investigate what is going on here, as I see no reason in principle that this should not work. |
Note to self for investigative context - in
|
The issue here is that this value is not being passed through as a computed key. |
I'm seeing the same issue on 0.6.16. Is this related? |
@coutotyler Can you show a configuration for 0.6.16? I suspect this was always broken and people are discovering it now that maps are a more prominent feature. I have a fix in the works for the 0.7 at the moment. |
Is it possible at all ( in v0.7rc-2) to define a list of maps? ( If I understand it well, the 'services' variable is a list, where each element of the list is a map.) |
@ocsi01 Yes - the services variable in this example is a list of maps, where each element is a map. Nested maps are supported internally but are not exposed via HCL syntax at the moment. |
@jen20 Does it mean at the moment ( v0.7rc-2) it's not possible to define multiple element in the 'services' list?
I'm getting syntax error:
As a workaround, I've found this syntax:
It is working well if I'm adding it as direct input to a module. However if I'm trying to pass it to an other module, I'm getting an error:
Any ideas? |
The reproduction of issue #7421 involves a list of maps being passed to a module, where one or more of the maps has a value which is computed (for example, from another resource). There is a failure at the point of use (via lookup interpolation) of the computed value of the form: ``` lookup: lookup failed to find 'elb' in: ${lookup(var.services[count.index], "elb")} ``` Where 'elb' is the key of the map.
The reproduction of issue #7421 involves a list of maps being passed to a module, where one or more of the maps has a value which is computed (for example, from another resource). There is a failure at the point of use (via lookup interpolation) of the computed value of the form: ``` lookup: lookup failed to find 'elb' in: ${lookup(var.services[count.index], "elb")} ``` Where 'elb' is the key of the map.
As part of evaluating a variable block, there is a pass made on unknown keys setting them to the config.DefaultVariableValue sentinal value. Previously this only took into account one level of nesting and assumed all values were strings. This commit now traverses the unknown keys via lists and maps and sets unknown map keys surgically. Fixes #7241.
The reproduction of issue #7421 involves a list of maps being passed to a module, where one or more of the maps has a value which is computed (for example, from another resource). There is a failure at the point of use (via lookup interpolation) of the computed value of the form: ``` lookup: lookup failed to find 'elb' in: ${lookup(var.services[count.index], "elb")} ``` Where 'elb' is the key of the map.
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. |
Terraform Version
Terraform v0.7.0-rc2
Affected Resource(s)
Terraform core
Terraform Configuration Files
Expected Behavior
Expected the map to contain a entry for "elb". I seems like "computed" values can't be passed in maps
Actual Behavior
Errors:
${lookup(var.services[count.index], "elb")}
Steps to Reproduce
terraform plan
The text was updated successfully, but these errors were encountered: