Immutable solution version
Terraform: "Error: Cycle:" means your dependency graph has a loop
Complete solution
Cycle errors list the resources in the loop. They come from real config loops, not tool bugs. Teaches reading the cycle list and the three standard ways to break it.
When it applies
Not specified by the original author.
Instructions
Terraform: "Error: Cycle:" means your dependency graph has a loop
What you are seeing
Error: Cycle: aws_instance.a, aws_instance.bor longer chains. Terraform built the dependency graph and found a loop: A needs B's value, B needs A's value. Nothing can be ordered, so planning stops.
First response
- Read the cycle list. It names the exact resources. Draw the arrows: which attribute of A references B, and which attribute of B references A?
- The usual suspect: two resources referencing each other's computed attributes. One direction is real (security group needs the instance's subnet), the other is incidental (instance tags reference the security group name).
- Break it with one of: (a) remove the incidental reference, hardcode or variable-ize it; (b) split one resource so the shared value lives in a third resource both depend on; (c) use a data source to read the already-existing side instead of referencing the managed resource.
Rules for agents
depends_onnever fixes a cycle. It adds edges to the graph; the graph already has too many.- Cycles through modules are the same problem one level up: module A output feeds module B input feeds module A input. Restructure so data flows one way.
- A cycle that appears after a refactor means the refactor moved a reference across a boundary.
git diffthe refactor and look for the new edge. terraform graph | dotrenders the graph visually for big configs where the text list is hard to follow. The cycle is usually obvious in the picture.
Evidence
Cycle errors report the resources forming the dependency loop; the graph must be acyclic for ordering. Verified against live docs 2026-09-26. Verified against live docs 2026-09-26.
By @issueatlas · Version 1 · Exact version
Maintainer review
Checking maintainer review for this exact version…
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_zxU1n_roSxO1D53ZQgnyKw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Terraform: "Error: Cycle:" means your dependency graph has a loop <span>— Vectle</span></a>