-
Notifications
You must be signed in to change notification settings - Fork 1.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
Unable to use instance_template with instance_group_manager anymore #4934
Comments
Interesting.... I was unable to reproduce in Terraform v0.12.13, but when I upgraded to 0.12.15 I see the errors about cycles as well. I'll do some digging, but a potential fix would be to downgrade to 0.12.13 and see if that works for you |
Looks like this is caused by hashicorp/terraform#23374 It was introduced in terraform core version 0.12.14, so downgrading to 0.12.13 should work until the fix is ready. |
I've got a similar issue and tried downgrading but unfortunately that doesn't work:
|
Looks like the upstream PR was merged in, so I would guess this will be fixed in the next release of terraform core. Unfortunately there isn't a way to work around this within the provider itself |
terraform core version v0.12.16 has been released including the PR fixing the issue causing the problem. Thanks for pointing me on the correct upstream issue! It looks better but it does not seem to completely fix the issue: Here is the output with the same scenario (a change in the base image):
Then it works fine on the second execution (because it only remains resources to delete). The debug log is here: https://gist.github.com/migibert/c88cfac6020761c9d7f903251d047574 |
This looks like a provider problem now! What is happening is that terraform builds a graph of operations that need to occur to get to the intended state, in this case that looks something like:
Where we create the new template before anything else, but then updating the IGM and deleting the old template happen in parallel. This is an issue because the API requires us to update the IGM before deleting the old template, as the IGM references the old template. I imagine something changed in how terraform core builds the graph between the last couple versions which is why we are seeing this now. I would guess that we were getting lucky in the ordering of operations before, causing the update to the IGM to happen before the delete. I believe I can fix this by adding a retry to the delete of the instance template, so that it will wait long enough for the IGM to be updated to not reference it anymore |
Not entirely sure this is a provider issue anymore. I've filed an issue upstream about the change in behavior between 0.12.13 and 0.12.16. |
Thanks for investigating, I will closely monitor the upstream issue! |
Going to close this out as it should be fixed in the next version of terraform core via that upstream issue and fix |
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. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Community Note
Terraform Version
Terraform v0.12.15
Affected Resource(s)
Terraform Configuration Files
A reproducer code is available here: https://gist.github.com/migibert/a51ad6521f565f4060aedd93b4337c33#file-reproducer-tf
Debug Output
https://gist.github.com/migibert/a51ad6521f565f4060aedd93b4337c33#file-tf-output-log
Panic Output
No Panic Output
Expected Behavior
I am using instance templates with images and instance group manager to manage an immutable infrastructure pattern.
I have been using this configuration from ~1 year and it used to run without any problem.
Actual Behavior
When I update the base image for a template, a cycle is detected and an error raises, preventing the update of the infrastructure.
Steps to Reproduce
terraform apply
to create the basic configuration (an IGM with 2 templates using using a base image)terraform apply
to update the configuration (an IGM with 2 templates using using a base image)Important Factoids
I tried with both a user account and a service account but none works.
My hypothesis is that it is related to lifecycle create_before_destroy instruction because here is the workaround I found...
BUT! Despite the errors, it creates the templates (it just fails to delete the old ones).
References
The text was updated successfully, but these errors were encountered: