What is Terraform state and why must it be stored remotely in a team environment?

Medium Topic: Terraform May 24, 2026

Terraform state is a JSON file (terraform.tfstate) that maps your configuration to real-world resources. Terraform uses it to know what already exists before planning changes.

Storing it locally breaks team collaboration:

  • Team members would each have different state files causing conflicts
  • State file gets lost if the local machine breaks
  • No locking mechanism — two engineers could run apply simultaneously and corrupt state

Remote backends (S3 + DynamoDB for locking, GCS, Terraform Cloud) solve all three problems.

terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    key            = "prod/terraform.tfstate"
    region         = "us-east-1"
    dynamodb_table = "terraform-lock"
  }
}
← Previous What is Infrastructure as Code (IaC) and what... Next → How do you manage multiple environments (dev/staging/prod) in...

Practice Similar Questions

Back to Terraform Topics