Chapter 27 · Part 5

Environment, Workspace, and State Management

A focused chapter on environment, workspace, and state management, with practical delivery concerns, trade-offs, and the operational questions behind CI/CD work.

27-1

Why State and Environment Management Matter Before Your Infrastructure Breaks

Imagine you and a teammate are both managing the same server. You update the firewall config to open port 443. Your teammate, without knowing, changes the

6 min
27-2

Stop Mixing Environments: Why Your Dev and Prod States Should Never Touch

You have three directories: dev, staging, and prod. Each one holds configuration files, state records, and resource definitions. When you need to update a

6 min
27-3

Where Should You Store Your Infrastructure State? A Practical Guide

You have just finished writing a Terraform configuration that provisions a handful of servers and a database. You run terraform apply on your laptop, and

6 min
27-4

When Two People Change the Same Infrastructure State at the Same Time

Imagine this: Developer A and Developer B both need to update some infrastructure. They pull the current state from the same S3 bucket, each makes their

4 min
27-5

When One Infrastructure Config Has to Serve Multiple Environments

You have a Terraform configuration that defines your VPC, subnets, and load balancer. It works perfectly for your development environment. Now you need

5 min
27-6

Who Owns Production? Why Privilege Boundaries Matter Between Environments

A developer on your team makes a small change to a configuration file. They meant to update the staging environment, but they accidentally ran the command

6 min
27-7

When Your Infrastructure State Doesn't Match Reality

You set up your infrastructure as code. Terraform, Pulumi, or whatever tool you chose. Everything is tracked, versioned, and repeatable. Your state file

6 min
27-8

When Your Terraform State File Disappears: Recovery Strategies That Actually Work

You run terraform plan and instead of the usual output, you get an error. The state file is missing. Or corrupted. Or locked by a process that died hours

6 min