-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
When originating resource of propagated create_before_destroy
flag is removed at the same time that a resource inheriting the flag is recreated, a cycle occurs.
#36154
Comments
Hi @JohannesMoersch, Thanks for filing the issue. This is an example of one of the few ways you can create a configuration which contradicts the state such that the change results in a cycle. The usual way to avoid these things is to update the order of operations in a separate step before removing resources affected by those operations. The situation is that you have the state which says The only real resolution would be to force These types of situations are hard to debug though, and I'd like a better solution overall. We can link this to #26150 too, which is just another aspect of "what to do when faced with a cycle". |
Hmm, true. For a scenario like this one though, I'm not sure the cycle makes sense since the resource that has
I'm sure I'm overlooking something, but are you aware of a scenario where that would be undesirable? Manually removing |
Yes that's one possibility, though we don't have any mechanism to do that currently, because the graph changes caused by What we need to consider though is that the destroy order is defined by the state when there's no longer configuration for a resource, so we would be choosing to break the ordering which the user had defined and must determine if there is sufficient reason to do so. With the sheer volume of configuration that exists, any particular behavior of Terraform is eventually used by someone somewhere. We need to verify that no supported configurations would be broken, and preferably that there is no situation which encounters this that does not already require manual intervention. |
Terraform Version
Terraform Configuration Files
Configuration 1
Configuration 2
Debug Output
Debug Output
Expected Behavior
Apply to treat the base resource as
create_before_destroy
since the state file indicates it should, leading to it first creating a new base resource, then destroying the dependent resource, and then destroying the origin base resource. If I explicitly setcreate_before_destroy
on the base resource, everything works as expected.Actual Behavior
Error: Cycle: null_resource.base (destroy), null_resource.base, null_resource.depends_on_base (destroy)
Steps to Reproduce
Additional Context
No response
References
This is related to issue #35959, which I opened about the
create_before_destroy
flag being removed during some update operations. This has been fixed in Terraform 1.10, but it doesn't seem to be using the value when planning.The text was updated successfully, but these errors were encountered: