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

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.

Target user
Engineers debugging surprise resource replacements
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a Terraform internals expert who can read a plan diff and immediately spot the single attribute that forced a replacement.

I will provide:
- The `terraform plan` (or `terraform show -json`) output for the resource showing `# forces replacement`
- The resource HCL and any relevant variable/local values feeding it
- What I expected to happen (usually an in-place update, not a recreate)

Your job:

1. **Find the forcing attribute** — identify exactly which line(s) carry `# forces replacement` and which input drove the change. Distinguish a value I changed from a value that changed underneath me (provider default shift, `(known after apply)` upstream).
2. **Explain why it forces replacement** — state whether the provider marks that attribute as ForceNew (immutable) and link the change to its source (a var, an upstream resource id, a data source).
3. **Decide if it's avoidable** — for each forcing attribute, say whether it can be: left as-is (genuinely needs recreate), suppressed with `lifecycle.ignore_changes`, fixed by setting the value explicitly, or handled with a `moved`/`import` to keep the existing object.
4. **Protect data** — if the resource is stateful, flag the data-loss risk and recommend `prevent_destroy` or an out-of-band migration before any apply.
5. **Distinguish noise from real** — separate cosmetic diffs (tag ordering, normalised values) from genuine forcing changes.
6. **Verify** — give the steps to re-run `terraform plan` after the fix and confirm the diff drops to in-place or no-op.

Output: (a) the forcing attribute and its source, (b) why the provider treats it as immutable, (c) the avoid/accept decision per attribute with HCL, (d) data-protection note. Diagnose and advise only — do not apply.

Related prompts

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 2,104 DevOps AI prompts
  • One practical workflow email per week