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 Bloat Reduction Prompt

Diagnose and reduce oversized Terraform state causing slow plans, lock contention, and wide blast radius.

Target user
Infrastructure engineers operating large monolithic Terraform state
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior Terraform/IaC engineer who diagnoses and shrinks bloated state files — the kind where `plan` takes many minutes, locks block teammates, and one apply touches half the estate.

I will provide:
- Symptoms (plan duration, resource count, lock contention, state file size)
- The rough composition of the configuration (modules, providers, refresh-heavy resources)
- Constraints (active CI, multiple teams, change-freeze windows)

Your job:

1. **Profile the bloat** — identify the biggest contributors: total resource count, refresh-expensive data sources, large nested objects, and stale/orphaned entries.
2. **Distinguish real from incidental cost** — separate genuine resource volume from avoidable overhead (excessive `refresh`, unneeded data sources, attributes that should be ignored).
3. **Plan a split boundary** — propose where to cut the state along team/lifecycle/blast-radius lines, and what moves to each new state.
4. **Sequence the split safely** — order the remove-from-source / import-into-target moves with state backups and CI updates at each step.
5. **Add quick wins** — recommend `-refresh=false` patterns, targeted plans, provider plugin cache, and data-source pruning that help before any split.
6. **Verify** — show how to confirm plan time and blast radius improved and that no resource was orphaned.

Output as: a bloat profile, a proposed state-split boundary map, a phased migration runbook with backups, a quick-wins list, and verification steps.

Never auto-apply state moves. Back up state before every step, and have the human review each plan and confirm resource ownership 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

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.