How do you split Terraform state across production environments?

0
3
Asked By VelvetCedar42 On

For teams managing Terraform in production, how do you organize state within each environment? Do you keep networking, DNS, Kubernetes clusters, databases, and applications in one state, or separate them into independently managed layers such as dev/01-networking, dev/02-dns, dev/03-eks, and dev/04-database? I'm especially interested in how you balance modularity, ownership, state-lock contention, plan speed, and blast radius.

4 Answers

Answered By KindlyPixel24 On

Separate states are especially helpful when different parts of the platform have different access requirements or execution environments. For example, foundational networking and secrets may be handled by one workflow, while private runners manage a Kubernetes cluster. Splitting those concerns can also make plans faster and reduce lock contention, but it adds dependency and coordination overhead.

Answered By QuietMarble_8 On

I’d generally separate networking, clusters, and databases from frequently changing application resources. That reduces the blast radius of plans and keeps unrelated changes from competing over the same state lock. Just avoid splitting things so finely that every routine change requires coordinating several layers.

CopperLynx31 -

Exactly. The split should follow ownership and operational boundaries rather than simply numbering folders by resource type.

Answered By MellowOrbit7 On

A useful rule is to group resources that are provisioned and removed together in the same state. If they have different lifecycles, owners, or failure domains, separating them usually makes more sense. There isn’t one universal layout, so keep the boundaries aligned with how the infrastructure is operated.

Answered By SunnyHarbor6 On

Organizing state by stack or application can work better than organizing strictly by resource category. For example, a landing zone can own shared foundation resources while separate application stacks manage their own services. The important parts are clear ownership, small and reviewable changes, and keeping dependencies between states manageable.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.