You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to create a number of similar resources with different configuration based on an array of maps (or objects).
Basically I'm trying to use the for_each in resource in the same way that dynamics do but this is failing.
Attempted Solutions
I tried the following but it crashes with "panic: not a string".
var.spec.databases is an array of maps (can also be a more complex object).
For the crash, this is a known issue with 0.12.6, and will be fixed in 0.12.7 #22279.
However, the way to get the behavior you're seeking is to use a map as for_each is designed:
{
dev = { ... some dev settings ... },
staging = {... some staging settings ... }
}
You would then be able to use the lookup function in your configuration on each.value. for_each does not support lists because it creates resources identified by the keys in the map (or set of strings, if one is used).
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.
ghost
locked and limited conversation to collaborators
Sep 20, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Current Terraform Version
Use-cases
I need to create a number of similar resources with different configuration based on an array of maps (or objects).
Basically I'm trying to use the for_each in resource in the same way that dynamics do but this is failing.
Attempted Solutions
I tried the following but it crashes with "panic: not a string".
var.spec.databases
is an array of maps (can also be a more complex object).Proposal
Allow the for_each to be used in reources the same way that dynamic do.
Also having the iterator will be nice.
The text was updated successfully, but these errors were encountered: