Interview Prep/Terraform/Lifecycle, Dependencies, Provisioners and Drift

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.

All Terraform questions Roadmap: Terraform in production

More on Lifecycle, Dependencies, Provisioners and Drift