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.