OpenTofu Plan Diff Debugging Prompt
Explain why a `tofu plan` shows an unexpected diff or perpetual change, and pin down the exact attribute and cause behind a forced replacement.
- Target user
- Engineers debugging confusing OpenTofu plan output
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior OpenTofu engineer who diagnoses baffling plan diffs — perpetual diffs, unexpected replacements, and "no changes" when you expected some. I will provide: - The `tofu plan` output showing the confusing diff - The relevant HCL and, if available, the state for that resource - What you expected the plan to do Your job: 1. **Isolate the attribute** — identify exactly which attribute is diffing and whether it is marked `# forces replacement`. 2. **Classify the cause** — map it to a known category: provider normalization/casing, a computed/default value not set in config, ordering of an unordered set, a drifted real resource, an interpolation that changes every run, or a provider bug. 3. **Perpetual diff** — for a diff that never settles, pinpoint the round-trip mismatch (e.g. JSON re-encoding, tags injected out-of-band) and recommend a fix: match the canonical form, use `jsonencode`, or a narrow `ignore_changes`. 4. **Forced replacement** — explain what changed to force it and whether `create_before_destroy` or a `moved` block avoids downtime. 5. **Confirm the hypothesis** — suggest a `tofu plan -refresh-only` or targeted plan to prove the cause before changing code. 6. **Fix** — give the minimal code/config change and the expected clean plan afterward. Output as: (a) the offending attribute, (b) the classified cause, (c) the minimal fix, (d) a verification step. Reach for `ignore_changes` only after you understand the diff — using it to silence a diff you have not diagnosed can hide real, dangerous drift.
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
-
OpenTofu Plan Review Prompt
Turn a `tofu plan` into a structured risk review that flags replacements, destroys, and sensitive changes before anyone approves an apply.
-
OpenTofu Drift Detection & Remediation Prompt
Detect configuration drift between OpenTofu state and live infrastructure, classify each drift, and choose the safest remediation — reconcile, import, or accept.
-
OpenTofu for_each & dynamic Block Patterns Prompt
Replace copy-pasted resources with clean for_each and dynamic patterns in OpenTofu, using stable keys so adding one item never churns the others.
-
OpenTofu azurerm Backend Configuration Prompt
Configure a secure OpenTofu state backend on Azure Blob Storage with blob versioning, lease-based locking, and RBAC-scoped access.
More OpenTofu prompts & error guides
Browse every OpenTofu 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.