Interview Prep/Terraform/State Backends and Workspaces

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 →

  1. Create the bucket once with a tiny bootstrap stack that uses local state, or with the CLI.
  2. Then optionally migrate that stack's state into the new bucket.
  3. 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.

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces