← Terraform & Infrastructure as Code learning pathTerraform & Infrastructure as Code · Module 4 of 10
State management
Understand and protect Terraform state.
📖 Key ideas
- State (terraform.tfstate) maps your config to real resources.
- Never edit state by hand; use terraform state commands.
- Teams store state remotely: S3 + locking, GCS, Azure Blob, Terraform Cloud.
- State locking prevents two people applying at once.
- 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