Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Terraform Difficulty: Intermediate ClaudeChatGPT

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

More Terraform prompts & error guides

Browse every Terraform prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.