Local vs Remote State
What you'll learn: You'll understand the key differences between storing infrastructure state files on your local machine versus a shared remote backend, and when to use each.
What Is Local State?
When you first start using Infrastructure as Code tools like Terraform, your state file is typically stored on your local machine — right in your project directory. This is called local state. It's simple: you run your IaC commands, and the state file sits there alongside your configuration files. This works great for learning, experimentation, or solo projects where only you touch the infrastructure.
What Is Remote State?
Remote state means storing your state file in a centralized, shared location — like an S3 bucket, Azure Blob Storage, or a specialized backend service. Instead of living on your laptop, the state becomes accessible to your entire team and your automation pipelines.
Why Does This Matter?
Think of local state like keeping your team's project notes in a personal notebook. It's fine when you're working alone, but collaboration becomes impossible. Remote state is like moving those notes to a shared Google Doc — everyone sees the same information, and changes don't conflict.
Key problems with local state in team environments:
- No collaboration: teammates can't see or coordinate changes
- No locking: two people might modify infrastructure simultaneously, causing conflicts
- Loss risk: if your laptop dies, so does your state
- No automation: CI/CD pipelines can't access your local files
Remote state solves these issues by providing a single source of truth that's accessible, protected, and often includes state locking to prevent concurrent modifications.
Key Takeaway: Local state is convenient for solo development and learning, but remote state is essential for team collaboration, automation, and production environments where multiple people or systems need safe, coordinated access to infrastructure state.