Why do `create_before_destroy` and dependencies sometimes cause "Cycle" errors?
AdvancedConceptLifecycle, Dependencies, Provisioners and Drift
Answer
create_before_destroy reverses the destroy ordering for that resource and its dependencies, so a dependency edge may be satisfied in one direction for create and the opposite for destroy, forming a cycle. Run terraform graph -type=plan to see it, then break the loop by removing the unnecessary reference, splitting the resource (for example separate aws_security_group_rule) or setting the lifecycle flag consistently.
More on Lifecycle, Dependencies, Provisioners and Drift
What are meta-arguments?BeginnerWhat lifecycle options are available?BeginnerHow does `create_before_destroy` work and what can go wrong?AdvancedWhat does `prevent_destroy` guarantee and what does it not?AdvancedWhen do you use `ignore_changes`?IntermediateWhat does `replace_triggered_by` do?Advanced