OpenTofu Drift Detection & Remediation Prompt
Detect configuration drift between OpenTofu state and live infrastructure, classify each drift, and choose the safest remediation — reconcile, import, or accept.
- Target user
- Platform engineers keeping OpenTofu state truthful
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who runs drift detection on OpenTofu-managed infrastructure and decides, per drift, whether to reconcile, adopt, or ignore it.
I will provide:
- The `tofu plan` / drift-detection output (refresh-only or full plan)
- What changed out-of-band and by whom (if known)
- Whether the environment tolerates a corrective apply now
Your job:
1. **Establish the source** — run a `tofu plan -refresh-only` mentally against the output to separate real drift (infra changed under you) from config changes (you changed code).
2. **Classify each drift** — for each resource, decide: (a) revert to code (someone hand-edited infra), (b) adopt into code (a legitimate change that should be codified), or (c) accept/ignore (managed elsewhere; consider `ignore_changes`).
3. **Assess blast radius** — flag whether reconciling would replace or disrupt a resource, and whether it touches data or networking.
4. **Remediation plan** — for revert cases, sequence the corrective apply; for adopt cases, describe the code change and re-plan; for ignore cases, propose a `lifecycle { ignore_changes }` scope that is as narrow as possible.
5. **Prevent recurrence** — recommend guardrails (deny out-of-band console changes, drift alerts on a schedule in CI).
6. **Verify** — a follow-up plan should be clean.
Output as: (a) a per-resource drift table with a decision, (b) the corrective actions, (c) a prevention note.
A corrective apply can revert a change someone made deliberately for a reason you do not know — confirm the intent behind each drift before reconciling in production.
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
-
OpenTofu Plan Review Prompt
Turn a `tofu plan` into a structured risk review that flags replacements, destroys, and sensitive changes before anyone approves an apply.
-
OpenTofu State Import & Migration Prompt
Bring existing, unmanaged infrastructure under OpenTofu safely using import blocks and generated config, or move resources between state files without recreating them.
-
OpenTofu CI/CD Pipeline Design Prompt
Design a safe OpenTofu CI/CD pipeline — fmt/validate, plan-on-PR with a saved plan artifact, gated apply-on-merge, locking, and least-privilege cloud auth.
-
OpenTofu azurerm Backend Configuration Prompt
Configure a secure OpenTofu state backend on Azure Blob Storage with blob versioning, lease-based locking, and RBAC-scoped access.
More OpenTofu prompts & error guides
Browse every OpenTofu 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.