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
-
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 RDS Zero-Downtime Change Plan Prompt
Analyze an RDS/Aurora terraform plan to tell in-place modifications from replacements, and sequence changes so the database isn't recreated or taken offline.
-
Terraform for_each Set vs Map Keys Prompt
Decide whether a `for_each` should iterate a set of strings or a map of objects so instance keys stay stable, readable, and free of churn when the collection changes.
-
Terraform Removed Block Forget-Only Prompt
Use a `removed` block with `lifecycle { destroy = false }` to drop a resource from Terraform management without destroying the real infrastructure — the declarative replacement for `terraform state rm`.
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.