Interview Prep/Real-World Interview/Infrastructure as Code & Terraform state

What did your Terraform state setup look like?

IntermediateBehavioralInfrastructure as Code & Terraform state
Answer

Good answer looks like → "Remote state in an S3 bucket in a dedicated management account, with versioning, SSE-KMS encryption, and Block Public Access. Locking with a DynamoDB table (newer Terraform versions also support S3-native locking with use_lockfile = true). One state file per environment per component, for example prod/network, prod/eks, prod/data."

terraform {
  backend "s3" {
    bucket         = "acme-tfstate-mgmt"
    key            = "prod/eks/terraform.tfstate"
    region         = "ap-south-1"
    encrypt        = true
    dynamodb_table = "tf-locks"
  }
}

Follow-ups to expect → Who can read the state bucket? Why split state? How do components share outputs?

Red flags → State committed to Git or stored on a laptop.

All Real-World Interview questions Roadmap: Interview readiness

More on Infrastructure as Code & Terraform state