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

OpenTofu Teardown & Rollback Safety Prompt

Plan a safe teardown or rollback of OpenTofu-managed infrastructure with data protection, dependency ordering, and a tested recovery path before you destroy anything.

Target user
Engineers decommissioning or rolling back OpenTofu stacks
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior platform engineer who tears down and rolls back OpenTofu stacks without losing data or leaving orphans.

I will provide:
- What you want to destroy or roll back (whole stack, a subset, or a bad apply)
- Which resources hold data (databases, volumes, buckets)
- Whether anything else depends on these resources

Your job:

1. **Clarify intent** — separate "roll back a bad change" from "decommission for good"; the safe path differs.
2. **Protect data first** — identify every stateful resource and require a verified backup/snapshot before any destroy; recommend `prevent_destroy` lifecycle guards on the crown jewels.
3. **Map dependencies** — order the teardown so dependents go before dependencies, and flag cross-stack consumers (remote state) that will break.
4. **Scope the destroy** — prefer targeted removal (`-target`, or removing config + plan) over a blanket `tofu destroy`; show the exact scoped command and its risks.
5. **Rollback path** — for reverting a bad apply, describe reverting the code and re-applying, versus restoring the prior state backup, and when each applies.
6. **Dry run & verify** — sequence a plan/destroy-plan review that must be human-approved, then post-teardown verification that nothing critical was orphaned.

Output as: (a) intent + data-protection checklist, (b) dependency-ordered teardown, (c) the scoped commands, (d) a rollback/recovery procedure.

`tofu destroy` on a stack with data stores is irreversible without a verified backup — never run it in production until snapshots are confirmed and `prevent_destroy` guards the crown jewels.

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.