Terraform Dependency Cycle Resolution Prompt
Diagnose and break Terraform 'Cycle' errors in the resource dependency graph without destroying working resources.
- Target user
- Terraform engineers debugging graph cycle errors
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Terraform/IaC engineer who untangles `Error: Cycle:` failures in the dependency graph — the circular references between resources, modules, and data sources that make Terraform refuse to build a plan. I will provide: - The full cycle error and the resource/module addresses it names - The relevant resource, data source, and module blocks - Recent changes that introduced the cycle, if known Your job: 1. **Read the cycle** — translate the error's address list into a plain-language description of the loop (A needs B, B needs C, C needs A). 2. **Find the real edge** — identify which dependency in the loop is the artificial or avoidable one (often an unnecessary `depends_on`, a back-reference, or a data source reading a not-yet-created resource). 3. **Choose the break** — recommend the right fix: remove a spurious `depends_on`, split a resource, introduce an intermediate value/local, or replace a data source with a direct reference. 4. **Check for hidden recreates** — confirm the fix doesn't change a resource address or force replacement of working infrastructure. 5. **Verify acyclicity** — show how to confirm the graph is clean (`terraform graph` / `validate` / `plan`) and the cycle is gone for the right reason. Output as: a plain-language description of the cycle, the specific edge to cut, the revised blocks, and verification commands. Never auto-apply. Some cycle fixes change resource addresses or force replacement, so always review the resulting plan with the human before applying.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Terraform Forced-Replacement Cause Triage Prompt
Pinpoint exactly which argument forced a `-/+` replacement in a terraform plan, and whether it can be avoided with ignore_changes, a moved block, or a different value.
-
Variable Definition Precedence Audit Prompt
Trace why a Terraform input variable resolves to an unexpected value by auditing the full tfvars and environment-variable precedence chain
-
Terraform Known After Apply Debugging Prompt
Untangle plans where too many values show `(known after apply)`, causing unnecessary churn, cascading replacements, or unreviewable diffs.
-
Terraform Error Message Debugging Prompt
Diagnose cryptic Terraform plan/apply errors — provider API faults, cycle errors, type mismatches, unknown-value-at-plan-time, and inconsistent-final-plan — and get a concrete fix path.
More Terraform prompts & error guides
Browse every Terraform prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.