-
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
map variables should support interpolation #444
Comments
Ah, this isn't quite what I meant. I think there is a better solution to this problem. We're not very interested at this time to support interpolations within variables since then variables also need to be a separate phase of the dependency graph and we don't want to do that yet. There is another issue (tagged "docs") tracking this. We'll come up with some solution there. |
Just wondering what the suggested solution for this is? I am running into the same issue |
Can someone please link to the issue mentioned by mitchellh:
I've spent at least 15 minutes looking and have been unable to find a related one having |
I don't know which one @mitchellh was talking about but this looks a lot like #4084 to me. I posted a workaround there of using a module as a place to stash some data, but I don't think that workaround would work for storing a map as shown in this issue, since modules can only export flat strings. |
I have suffered same problem :( |
So no insights on this yet? It got me too. |
While recursive interpolation and interpolation within variables are still not features, I find the interpolation methods that are available now work well enough to get the job done.
do this:
|
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. |
I hit this problem while trying to find a solution to using the count parameter to create 3 subnets and then use those 3 subnets for 3 new instances. Mitchell suggested I use a map variable and then a lookup to get the subnet_id. Here's the code I tried.
The error I received when running 'terraform plan' was:
It was suggested by @mitchellh that I use a variable map to get to the newly created subnet_ids via the lookup function. Is there another way to do this that I'm not seeing?
Besides this not working, this is a really verbose and messy solution. I initially tried to use just a number for the key name, but terraform gave me an error. It seems like key names must start with a letter. This required me to use 'concat' to specify the correct key name for the lookup.
Ideally, I wish I was able to simply define in the aws_instance resource declaration the following:
This would require recursive string interpolation to be added though.
The text was updated successfully, but these errors were encountered: