Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for OpenTofu Difficulty: Advanced ClaudeChatGPT

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

More OpenTofu prompts & error guides

Browse every OpenTofu 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.