-
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
Circular dependency when provisioner for destroy references array member for AWS #17944
Comments
Thanks for filing this. Also, have you tested this with the current release? There were a few internal changes to the evaluation of destroy provisioners recently which may have indirectly fixed this. |
I will try to do it. The reason I haven't yet is that this is part of bigger solution and I had no time to extract this for testing. But If you can't reproduce I have to do it anyway. |
I had some more time to experiment and expanded this out to reproduce the cycle. |
A minimal test case for investigation:
Tainting
|
@jbardin exactly this is simplified to maximum my case ;) I guess that root cause is that this destroy provisioner is should not enforce dependency on resources referenced in it. Because in general this is what it is for - to remove this dependency prior to destruction ;) |
An interesting workaround here is adding The reason for the cycle is that normally destroy dependencies flow in reverse. Node The dependencies showing the cycle look like: And with We'll have to determine how we want to handle this after the next major release. I'm not sure if there's a good solution other than inverting the order, but at least we know it can be detected and reported fairly clearly to the user. |
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. |
To resolve problem with disk attachment on AWS (disk attachement cannot be destroyed when disk is mounted on OS level) I created following code:
When trying to rebuild instances (because AMI instances depend on) terraform reports circular dependency for this code. Experiment shows that the problem is with shell command - when reference
${element(aws_instance.myservice.*.id, count.index)}
is replaced with something different terraform works like a charm (production solution for me is to use AWS CLI to first find instance IDs and then use them to stop instances).Most probably root cause is wrong interpretation of interpolation of array member when building graph for rebuild.
Problem doesn't exist when
terraform destroy
is executed - only onterraform apply
which is expected to re-build instances.Terraform Version
Terraform Configuration Files
...
Debug Output
Crash Output
Expected Behavior
Actual Behavior
Steps to Reproduce
Additional Context
References
The text was updated successfully, but these errors were encountered: