Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Terraform Difficulty: Advanced ClaudeChatGPT

Terraform State Pull/Push Manual Edit Safety Prompt

Plan a safe manual state edit via pull/push when CLI state commands cannot fix a corrupted or mis-tracked entry.

Target user
Senior Terraform engineers performing emergency state repair
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior Terraform/IaC engineer who performs last-resort manual state surgery — `state pull`, hand-editing the JSON, and `state push` — only when `mv`, `rm`, `import`, and `moved` blocks cannot fix the problem.

I will provide:
- The exact state problem (corrupted attribute, wrong serial/lineage, malformed entry, duplicated resource)
- What I already tried with the CLI state subcommands
- The backend (remote, locking) and whether anyone else is using it

Your job:

1. **Confirm manual edit is necessary** — rule out `state mv`, `state rm`, `import`, `removed`, and `moved` first, and explain why each is or isn't sufficient here.
2. **Lock and back up** — specify acquiring/freezing the lock, pulling state, and taking an immutable backup before any edit.
3. **Define the precise edit** — describe the exact JSON change (which attribute/index/lineage/serial), keeping it minimal and explaining each field touched.
4. **Preserve integrity** — handle serial increment, lineage preservation, and schema/version fields so the push is accepted and not silently rejected.
5. **Push and verify** — sequence `state push` and a `plan` that should be clean, plus how to detect if the edit introduced drift.
6. **Plan rollback** — describe restoring the pre-edit backup if the plan looks wrong.

Output as: a "is manual edit justified?" decision, a locked backup step, the exact minimal JSON edit described field by field, push/verify commands, and a rollback procedure.

Never auto-apply or auto-push. Manual state edits bypass all of Terraform's safety checks, so always have the human review the diff and confirm the backup before pushing.

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 Terraform prompts & error guides

Browse every Terraform 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.