Who creates the state bucket itself, given Terraform needs it to exist before `init`?
IntermediateScenarioState Backends and Workspaces
Answer
Situation read → Bootstrap problem.
What I'd do →
- Create the bucket once with a tiny bootstrap stack that uses local state, or with the CLI.
- Then optionally migrate that stack's state into the new bucket.
- Keep the bootstrap code in Git with a README.
aws s3api create-bucket --bucket acme-tfstate-prod --region ap-south-1 \
--create-bucket-configuration LocationConstraint=ap-south-1
aws s3api put-bucket-versioning --bucket acme-tfstate-prod \
--versioning-configuration Status=Enabled
Why → There's always one thing created outside the system; make it tiny, documented and rarely touched.
Interview tip → Account vending pipelines usually create it automatically.
More on State Backends and Workspaces
Two engineers keep overwriting each other's changes because state is local. What's the fix?BeginnerSet up a production-grade S3 backend. What do you configure for locking?IntermediateHow do you harden the S3 bucket that holds Terraform state?IntermediateA laptop apply and a CI apply start at the same time. What stops state corruption?IntermediateWhen are Terraform workspaces appropriate?BeginnerCompare directories, workspaces and branches for environment separation.Intermediate