-
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
Interpolated count values differ after the initial apply #13867
Comments
I attempted to fix this by ignoring a rename if there's another resource in the state that ends in ".1" However, this means that if we do actually modify the count to 1, the other resources are deleted and 1 resource will be created with the removed ".0" ( This renaming business seems error prone. Maybe we could just always have a .0 whenever a count is defined, even if it happens to only equal 1. |
Sounds like another case possibly resolved by #13793. @saracen - if you are hacking the source directly - can you see if adding the transformer to the plan graph builder fixes the issue for you? Also I think that having |
@vancluever Early indications seem that it's working great! I added a bunch of weird workarounds and static values to my configs because I've got a deadline. But I'll be gradually removing more of those today and testing this out. Thank you so much for this solution and spotting this issue at a weekend! |
@saracen no problem and happy to hear things are working for you! |
@vancluever Something still seems to be a problem somewhere, but I haven't tracked down whats causing it yet. I can do a bunch of updates, and then I eventually hit a cycle error. When listing the state, I see that an instance of a resource without the count suffix has been introduced:
Removing it fixes the cycle problem. When I'm free I'll try to come up with something that's repeatable. |
@saracen there definitely seems to be a case where this is still happening (see #13828 for a repro). Looking into it a bit more I'd imagine that there's still something a little amiss where on refreshes the resource does not exist for interpolation like it should... I'm still in the process of tracking it down but probably won't be able to look that much more into it until the evening. |
I just got bit badly by this bug. It was while developing a plugin which made it worse because I kept assuming it was a bug in the plugin... It seems it can manifest itself in 2 ways:
or with the .0 disappearing, which in my case resulted in
I don't have much to add except that i hope it's fixed soon |
Hi folks, |
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. |
Creating a resource with an interpolated count works on the very first apply. Subsequent plans and applies that cause the resource to be modified will change the name of the resource. This can lead to issues where there are references to resources that terraform doesn't believe exist, however they do... just under a slightly different name.
From my debugging it appears that
EvalCountFixZeroOneBoundary
is executed in two passes. After modification of a resource containing a count, the first pass will always return a count of 1 (andcount
appears in the RawConfig'sunknownKeys
). The second has the correct value, but by this point, the resource name has already been replaced with a string that has trimmed the ".0" from the end.Terraform Version
Terraform v0.9.3
Affected Resource(s)
Affects core
Terraform Configuration Files
Expected Behavior
Resource names should be consistent as per the initial apply.
Actual Behavior
Resource names are modified on later applies/plans. The ".0" prefix is removed:
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
terraform plan/apply after a modification that causes an update to the resource with a count
References
The text was updated successfully, but these errors were encountered: