-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Terraform maps - Destroys and creates additional resources based on the alphabetical order of first letter in param name #14477
Comments
Im using this inside an ALB module to add rules under the listener of the ALB
Everything went ok, now in my second run.
as "/v1/customers*" is now the first element of the list (keys(services_map)). |
Not sure what the roadmap is here, but would love to see terraform resources have the concept of Primary difference being, it accepts a map as the input, and that when the resulting tfstate is created it will use the This way as keys come and go from a map, you don't have to worry about the order of keys() causing resources to be re-created un-intentionally. |
I ran into this today, fortunately in a testing environment. At the very least it would be nice if this was explicitly articulated in the variable documentation for maps. Terraform version 0.11.3. Using a map variable to deploy a series of docker containers and configuration variables. I attempted to add a second container configuration to the deploy which happened to be keyed alphabetically earlier than my original. When planning, terraform was attempting to create a duplicate of my original as it was now the second index in the map. |
Hi all! Sorry for the long silence here. I missed this issue before. This seems like the same thing being discussed in #17179, where I posted earlier our current thinking about how to address this. It's actually very similar to what @jmeisner3 suggested here, albeit with some different attribute/reference names. As noted over there, we're planning to do this once we've completed some prerequisite work on how Terraform thinks about configuration in general. That work is the current focus for the Terraform Team at HashiCorp and will be included in a future release. I'm not sure yet if the proposed I'm going to close this issue just to consolidate the discussion over in #17179. Thanks for opening this issue, and sorry again that I missed it while posting updates. |
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. |
Hi there,
Terraform Version
0.9.5
Affected Resource(s)
Affects multiple AWS resources that use maps.
Terraform Configuration Files
Issue
If record "a" is created after record "b" then record "b" should not be re-created. This appears to be due to Terraform maps using the alphabet for ordering.
e.g
record_value = {
"b" = "10.0.0.1" - Terraform resource name: aws_route53_record.record_value.0
}
If you add another parameter:
record_value = {
"b" = "10.0.0.1" Terraform resource name: aws_route53_record.record_value.1
"a" = "10.0.0.2" Terraform resource name: aws_route53_record.record_value.0
}
When "a" is added it now has the resource name aws_route53_record.record_value.0 due to a coming before b in the alphabet. So resource b is then deleted and created with resource name aws_route53_record.record_value.1
Is it possible to fix this issue? This is an issue especially if something is relying on a resource that is re-created.
The text was updated successfully, but these errors were encountered: