-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Interpolating name of resource causes recreation when value hasn't changed #3744
Comments
Hi @jurajseffer! 👋 Sorry you're running into unexpected behavior here. Two questions:
I have a feeling that Terraform core (nothing in the AWS provider) might be confused about computing the attribute with the ternary operator and showing the unexpected difference. |
Thanks for your reply @bflad. Plan shows this for the ASG resource when LC needs to be recreated:
Apply fails because it does try to create the new resource first as per my lifecycle policy: |
Also once I've applied the above and it failed, TF created new launch configuration and the next plan shows it wants to update |
@jurajseffer can you provide a bit more information on the
|
Hey @FrenchBen, the reason for that interpolation of LC id into ASG name is to provide rolling deploys for ASGs with "create before destroy" and Ansible local-exec to provide transition from old into a new ASG. My twist on it with the switch is because some of our existing ASGs cannot be redeployed this way and we wanted to retain backwards compatibility with existing ASGs. I've not tried locals with it, good shout, it might be a workaround unless Terraform does lazy evaluation? I.e. it would just take the locals statement and evaluate it within the ASG context anyway. |
@jurajseffer I may be missing the bigger picture - My understanding of having |
The launch configuration is immutable so AWS recreates it every time we change it. We use |
We're seeing this same behavior in terraform in our case we have
even with
|
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Terraform Version
Terraform v0.11.1
Affected Resource(s)
Terraform Configuration Files
changing to
Expected Behavior
aws_autoscaling_group
resource is updated without recreating it.Actual Behavior
Once we've added the true/false logic with
switch
=false
andaws_launch_configuration.lc
needing to be recreated, Terraform thinks the entire ASG needs to be recreated (destroy+create) even though the result of the name interpolation remains the same, i.e. concatenation of a,b and c variables. This seems to happen only once when switching from simple concat to the true/false logic with concat.The text was updated successfully, but these errors were encountered: