midDevOps
What is the Terraform State file?
Updated Apr 28, 2026
Short answer
The state file (terraform.tfstate) maps real-world cloud resources to your configuration files and keeps track of metadata.
Deep explanation
Terraform uses this JSON file to know what resources it currently manages. When you run terraform plan, it compares the real infrastructure, the state file, and your code to determine what changes are necessary. It is critical for the lifecycle mapping of IaC.
Real-world example
Storing the state file in an AWS S3 bucket so a team of 5 DevOps engineers can all run Terraform without conflicting with each other.
Common mistakes
- Committing the `terraform.tfstate` file to a public Git repository, exposing sensitive database passwords and infrastructure secrets.
Follow-up questions
- How do you prevent concurrent state modifications?