What is Terraform state and why should it be remote?
Assesses fundamental understanding of Terraform & IaC conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
Terraform state is a JSON file that maps your configuration to real infrastructure. It stores resource IDs, attribute values, and dependency metadata so Terraform knows what exists and how to change it.
Why remote state:
- Team collaboration: everyone reads and writes the same state instead of overwriting each other.
- Locking: backends such as S3 with DynamoDB, Azure Blob, or Terraform Cloud lock state during operations, preventing concurrent corruption.
- Durability and security: state often contains secrets, so store it in encrypted, access-controlled storage with versioning.
- CI/CD: pipelines can use the same state from any runner.
terraform {
backend "s3" {
bucket = "my-tf-state"
key = "app/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "tf-locks"
encrypt = true
}
}
Never commit state to Git. Back it up and treat it as sensitive.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.