Lesson 1 of 5 ยท Terraform State & Drift Detection
Terraform state as an infrastructure inventory
Terraform state is its record of the infrastructure it manages. It maps an address from configuration, such as aws_vpc.main, to a real provider object and remembers values Terraform needs to compare future changes. State is operational data, not a disposable cache or a substitute for your configuration.
Example
resource "aws_s3_bucket" "assets" {
bucket = "team-assets-example"
}
# Terraform tracks this address in state:
# aws_s3_bucket.assetsStep by step
- Read a Terraform address as type plus local name.
- Treat state access as production access.
- Use a secured remote backend for shared work.
- Keep configuration as the reviewed description of intent.
Common mistakes to avoid
- Committing terraform.tfstate to a repository.
- Deleting state because an error is frustrating.
- Assuming state alone tells you what the intended architecture should be.