Interview Prep/Terraform/State and Backends in Production

How do you bootstrap the remote backend, given the bucket must exist before Terraform can use it?

IntermediateProductionState and Backends in Production
Answer

Create the state bucket once with a small bootstrap stack that uses local state (or the CLI or CloudFormation), then switch that stack's backend to the bucket and run terraform init -migrate-state. After that the bootstrap stack manages its own bucket. Keep this stack tiny, prevent_destroy = true, and documented, since it is the foundation everything else rests on.

All Terraform questions Roadmap: Terraform in production

More on State and Backends in Production