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.
More on State and Backends in Production
Why should Terraform state never be committed to Git?BeginnerWhat does a hardened S3 state bucket look like?IntermediateWhat is the minimum IAM permission set for the S3 backend?IntermediateHow do you move from DynamoDB locking to S3 native locking in a live fleet?IntermediateState was deleted or corrupted. How do you recover?AdvancedHow do you split a monolithic state and what drives blast-radius decisions?Advanced