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.
More on Infrastructure as Code & Terraform state
How did you structure your Terraform code?BeginnerWhy did you use folders per environment rather than Terraform workspaces (or vice versa)?IntermediateHow did different Terraform stacks share information?IntermediateDid you ever have a state lock or corrupted state? What did you do?AdvancedHow did you handle Terraform drift?IntermediateHow did you import existing resources into Terraform?Intermediate