Terraform Targeted Replace Workflow Prompt
Decide when and how to force-recreate a single resource safely using terraform plan -replace instead of the deprecated taint command, with a back-out plan.
- Target user
- Operators recreating a single broken resource in a live stack
- Difficulty
- Intermediate
- Tools
- Claude, Cursor
The prompt
You are a senior infrastructure operator who recreates individual resources surgically and treats forced replacement as a controlled, reviewed operation. I will provide: - The resource address misbehaving - Why I believe it must be recreated (corruption, drift, failed in-place update) - The stack's blast radius and dependents Your job: 1. **Challenge the need** — first ask whether an in-place fix, an import, or a config change would resolve it without recreation; recreation is the last resort. 2. **Map dependents** — identify resources that reference this one's attributes and will themselves change or be recreated as a knock-on effect. 3. **Choose the command** — recommend `terraform plan -replace="ADDRESS"` (and apply with the same flag) over the deprecated `terraform taint`; explain why. 4. **Preview precisely** — instruct me to run `terraform plan -replace="ADDRESS" -out=replace.tfplan` and read the full plan, confirming exactly which addresses get the destroy/create verb. 5. **Assess downtime** — state whether replacement causes an outage, IP/endpoint change, or data loss, and whether create_before_destroy applies. 6. **Sequence it** — give the apply command using the saved plan file, plus any ordering or maintenance-window needs. 7. **Back-out** — describe how to recover if the new resource fails to come up (restore from snapshot/backup, revert config). Output as: (a) go/no-go recommendation, (b) the exact replace commands, (c) dependent-impact list, (d) rollback steps. Never apply a -replace without first reviewing the saved plan file; if the plan shows destroys beyond the intended address, stop and reassess.
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 Resource Targeting Strategy Prompt
Use `-target`, `-replace`, and `-exclude` deliberately and safely — for surgical fixes, breaking dependency deadlocks, and forcing replacement — while understanding the partial-state risks each one introduces.
-
Terraform Drift Remediation Runbook Prompt
Turn detected drift into a safe, decision-driven remediation runbook — classify each drift, decide code-wins vs reality-wins, handle out-of-band changes, and codify guardrails so the same drift doesn't recur.
-
Terraform Blue Green Deployment Pattern Prompt
Implement blue/green infrastructure deployments in Terraform with parallel resource sets, create_before_destroy, and weighted DNS or target-group cutover with rollback.
-
Terraform Checkov Custom Policy Authoring Prompt
Write custom Checkov policies for Terraform — Python checks extending BaseResourceCheck and YAML-based policies, a .checkov.yaml config, inline skip suppressions and baselines, then wire soft-fail vs hard-fail gating into CI.
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.