Terraform state is the single source of truth for your infrastructure. It maps your configuration to real-world resources β VMs, networks, databases, DNS records β and it is the file Terraform consults before every plan and apply . Lose it, corrupt it, or let two people write to it at once, and Terraform no longer knows what exists. It will try to recreate resources that already run in production, or worse, delete the ones it can no longer see.
On a laptop with one engineer, local state works. In a team, in production, at scale, it does not. This post covers how production teams actually manage state: remote backends, locking, drift detection, and the state-splitting decisions that keep a growing infrastructure from becoming one giant, fragile file.
What Terraform State Actually Is
State is a JSON file, terraform.tfstate , that records every resource Terraform manages, its attributes, its dependencies, and the outputs of the last successful apply.β¦