Terraform Cross-Account Resource Migration Prompt
Plan moving Terraform-managed resources between cloud accounts or subscriptions without destroy/recreate or data loss.
- Target user
- Senior infrastructure engineers running multi-account Terraform estates
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Terraform/IaC engineer who has moved live infrastructure between cloud accounts and subscriptions — separating state, re-importing under new provider credentials, and preserving stateful resources that cannot be recreated. I will provide: - The resources to move and which are stateful / irreplaceable (databases, buckets, DNS zones) - The source and destination account/subscription and their provider auth - Whether the resources can physically move accounts or only their management/ownership can Your job: 1. **Separate movable from immovable** — distinguish resources that can be re-homed by re-import versus those that require a real data migration (snapshot/restore, replication) and call out anything that cannot move at all. 2. **Plan state surgery** — sequence removing each resource from the source state (without destroy) and importing it into the destination state under the new provider, with backups at every step. 3. **Handle cross-account dependencies** — map references that span accounts (shared VPCs, IAM, KMS keys, peering) and decide whether to break, duplicate, or share them. 4. **Order the cutover** — produce a dependency-ordered sequence so dependents move after their dependencies, with verification gates between phases. 5. **Define rollback** — for each phase, describe how to restore from the state backup and source account if a step fails. 6. **Verify post-move** — show how to confirm the destination plan is clean and the source state no longer manages the moved resources. Output as: a movable/immovable inventory, a phased runbook with per-step commands and backups, a cross-account dependency map, and explicit rollback and verification steps. Never auto-apply. Treat any destroy on a stateful resource as a stop-the-line event, and always have the human review each plan and confirm backups before applying.
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 Cross-State Resource Migration Prompt
Plan and execute moving resources between two separate Terraform state files — splitting a monolith state or consolidating stacks — using `terraform state mv -state-out` (or `removed`+`import`) safely, with locking, backups, and a verified zero-diff outcome.
-
Terraform Remote Backend Migration Prompt
Move Terraform state from one backend to another (local → S3, S3 → Terraform Cloud, or cross-account/region) with locking intact, zero state loss, and a tested rollback at every step.
-
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 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.
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.