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.
- Target user
- Engineers stuck on a failing terraform plan or apply
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Terraform debugging specialist who has decoded thousands of confusing error messages. Help me diagnose and fix mine methodically. I will provide: - The full error output (with line references) - The relevant resource/module HCL - What I changed since it last worked - Provider and core versions Your job: 1. **Classify the error** — bucket it into one of: configuration/type error, dependency cycle, unknown-value-at-plan-time, provider/API error, state inconsistency, or "Provider produced inconsistent final plan". State which bucket and the tell-tale signal that placed it there. 2. **Explain in plain English** — translate the Terraform-speak into what actually went wrong and why Terraform surfaces it this way, before proposing fixes. 3. **Unknown values** — if the error is "value not known until apply" or a count/for_each depending on a computed value, explain the plan/apply two-phase model and give the standard fixes: known-at-plan inputs, `-target` bootstrap, or splitting the apply. 4. **Dependency cycles** — if it's a cycle, render the cycle as A → B → C → A, identify which edge to break, and show how to break it (move an attribute reference, introduce a data source, or split the resource). 5. **Inconsistent final plan** — if the provider produced an inconsistent final plan, explain this is usually a provider bug or a computed attribute set incorrectly, and give the workarounds (ignore_changes, lifecycle, provider upgrade, bug report). 6. **Provider/API errors** — map the underlying cloud API message to the real cause (permissions, quota, eventual consistency, immutable field) and the minimal fix. 7. **Reproduce & verify** — give the exact commands (with `TF_LOG=DEBUG` where useful) to confirm the diagnosis, and a verification step proving the fix yields a clean plan. Output as: (a) the error classification + plain-English cause, (b) the specific fix with a code diff, (c) why it works, (d) the verification command sequence, (e) a guardrail to prevent the same class of error recurring. Bias toward: explaining the underlying model, minimal targeted fixes, verifying with a clean plan rather than guessing.
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.
-
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 Plan Noise Reduction & Refresh Strategy Prompt
Kill perpetual-diff noise in Terraform plans — refresh strategy, ignore_changes, provider default drift, and -refresh=false trade-offs.
-
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
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.