Local State Storage
What you'll learn: How Terraform stores its state file on your local machine by default and why this matters when working with a team.
Where Does Terraform Keep State?
When you run terraform apply, Terraform creates a file called terraform.tfstate in your current working directory. This is local state storage—the default behavior where your state file lives on your computer's filesystem, right alongside your .tf configuration files.
Think of it like keeping a personal notebook on your desk. It's convenient when you're working alone, but problems arise when your colleague needs to see the same notebook.
The Implications for Teams
Local state storage works perfectly for individual experimentation and learning. However, it creates serious challenges in team environments:
- No sharing: Each team member has their own separate state file on their laptop
- Conflicts: Two people might try to modify the same infrastructure simultaneously without knowing
- Risk of loss: If someone's laptop crashes or they delete the file, you lose track of your infrastructure
- No locking: Multiple
terraform applycommands could run at once, corrupting state
When you work solo on a small project, local state is simple and requires no additional setup. But the moment you collaborate, you need everyone looking at the same state file—which local storage cannot provide.
What This Means for You
As a beginner, local state is fine for learning and testing. Just remember that your terraform.tfstate file is critical: back it up, add it to .gitignore (never commit it to version control for security reasons), and understand you'll need a different approach when joining a team.
Key Takeaway: Terraform stores state locally by default in terraform.tfstate, which works for individual learning but breaks down when teams need to collaborate on the same infrastructure.