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.