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

How would you break a dependency cycle between two resources?

AdvancedConceptLifecycle, Dependencies, Provisioners and Drift
Answer

Find the loop (terraform graph | dot -Tsvg, or the error's list of nodes). The usual cause is two security groups referencing each other inline: split the rules into separate aws_security_group_rule or aws_vpc_security_group_ingress_rule resources so both groups exist first. Another trick is introducing an intermediate resource or passing a static name instead of an attribute.

All Terraform questions Roadmap: Terraform in production

More on Lifecycle, Dependencies, Provisioners and Drift