A circular dependency occurs when resources form a closed chain: one resource waits for another, which eventually waits for the first. Terraform models dependencies as a directed acyclic graph, so it cannot determine a creation or modification order for a cycle and fails during planning. section 1.3.3 section 5.2
Three resources caught in a cycle
Three null_resource instances can create the cycle alpha → charlie → bravo → alpha when each trigger references another resource's ID. Running terraform plan produces a Cycle error naming all three resources. The dependency may be indirect and can also arise between services, such as authentication and logging services that depend on each other. section 5.7.1
When Terraform reports a circular dependency:
- Inspect every resource named in the error and trace how their attributes connect. section 5.7.1
- Look for a shared attribute that can be generated independently as a variable or local value. section 5.7.1
- Prefer simpler dependency chains; a cycle often indicates architecture that is unnecessarily complex and harder to manage or debug. section 5.7.1
Figure 1.4 An example of a circular dependency in which resources are dependent on one another
Use the dependency graph to see how resources waiting on one another create a closed cycle with no valid launch order. section 1.3.3




