-
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
Overly aggressive change detection on AWS subnet_id property with count #4768
Comments
Sorry to see you're experiencing over-zealous diffing. I think this might be the same thing being discussed in #3449, but I'm not sure. In your first example, do you have The issue for #3449 is that a
Does that seem like a plausible explanation for what you're seeing? If so, I think this is a duplicate and I'd like to consolidate the discussion in the other ticket. In the mean time, a workaround for this issue would be to plan with On a longer ark, the new feature discussed in #4149 could ultimately (with some further architecture changes to how interpolations are resolved) help Terraform handle this situation better by automatically detecting that it doesn't have enough information to apply this whole config in a single step. |
Ah ha – there it is! Indeed, this behavior looks to be a dupe of #3449 (or, at least, would seem to be addressed by the fix there proposed). Thanks again for the prompt and thorough reply! :) |
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. |
Hello! When I have a terraform config defined as:
I have found that changing the count parameter to 3 produces an undesirable result:
Note the changes to targets "aws_route_table_association.r" and "aws_instance.r" – both of these resources will go through a create/destroy cycle to end up right back in the same subnet.
I would have expected a plan "2 to add, 0 to change, 0 to destroy" for the addition of the 2 as-yet-unreferenced subnets.
A valid workaround appears to be:
Change the
element(..., count.index)
references toaws_subnet.r.0.id
like so:Run
terraform apply
Change the
aws_subnet.r.0.id
back toelement(..., count.index)
At this point,
terraform plan
claims my infrastructure is up to date without requiring the destruction & recreation of my route table association or instance.Also of note is that the reverse, changing 3 back to 1, produces the expected result:
I haven't conducted an exhaustive survey of what resource types exhibit this behavior, but for what it's worth I have not observed similar problems with properties whose schemas are not flagged as
ForceNew: true
.The text was updated successfully, but these errors were encountered: