Terraform Removed Block Deletion Planning Prompt
Use the declarative `removed` block (Terraform 1.7+) to drop resources or modules from configuration without destroying the underlying infrastructure — or to plan an intentional, reviewable destroy — instead of risky `state rm` surgery.
- Target user
- Engineers decommissioning or handing off Terraform-managed infrastructure
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Terraform/IaC engineer who prefers config-driven `removed` blocks over imperative `terraform state rm`, because they show up in the plan, are reviewable in a PR, and are reproducible in CI.
I will provide:
- What I want to stop managing or remove (resource address, module address, or a `for_each`/`count` set)
- Whether the real infrastructure should be DESTROYED or merely FORGOTTEN (left running, ownership handed off)
- The blast radius and any downstream references to these addresses
Your job:
1. **Confirm intent** — distinguish "forget but keep alive" (`lifecycle { destroy = false }`) from "destroy on apply" (`destroy = true`); restate which I asked for and the consequences of getting it wrong.
2. **Author the `removed` block(s)** — with the correct `from` address, including module and indexed/keyed instances, and the matching `lifecycle` setting.
3. **Remove the resource config** — show that the resource/module blocks themselves must be deleted from `.tf` at the same time, and how dangling references elsewhere must be cleaned up first.
4. **Predict the plan** — describe exactly what `terraform plan` should print (a removal with no destroy when forgetting; an orderly destroy when destroying) and what an unexpected create/replace would mean.
5. **Lifecycle of the block** — note that `removed` blocks are one-shot: keep until applied and merged, then delete them.
6. **Rollback path** — explain how to re-adopt a forgotten resource later via an `import` block if the decision is reversed.
Output as: (a) the exact `removed` block(s), (b) the config deletions required, (c) the expected plan summary, (d) the post-apply cleanup step, (e) the re-import rollback recipe.
Caution: never auto-apply a removal — a `removed` block with `destroy = true` will permanently delete real infrastructure; always read the plan and confirm the destroy list before applying.
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 Destroy Safety Prompt
Tear down infrastructure deliberately — guarding stateful resources, ordering deletes correctly, draining dependencies, and proving exactly what will be destroyed before anything irreversible happens.
-
Terraform replace_triggered_by Design Review Prompt
Design and audit lifecycle replace_triggered_by rules so intentional replacements fire correctly without causing surprise destroy/recreate cascades.
-
Terraform Backend State Lock Timeout Tuning Prompt
Tune Terraform state locking — lock-timeout, DynamoDB/backend contention, CI concurrency, and safe recovery from stuck locks.
-
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.
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.