← Terraform & Infrastructure as Code learning path
Terraform & Infrastructure as Code · Module 4 of 10

State management

Understand and protect Terraform state.

📖 Key ideas

  1. State (terraform.tfstate) maps your config to real resources.
  2. Never edit state by hand; use terraform state commands.
  3. Teams store state remotely: S3 + locking, GCS, Azure Blob, Terraform Cloud.
  4. State locking prevents two people applying at once.
  5. State may contain secrets; encrypt and restrict access.
💡 Real-life example: State is Terraform's memory notebook of what it built; lose it and Terraform forgets everything.
State fileRecord of managed resources
Remote backendShared storage for state
State lockingPrevents simultaneous changes
terraform importBrings existing resources under management