Bootstrap remote state
Remote state is a prerequisite. Atlas does not treat local Terraform state as a valid operating mode for shared infrastructure.
Step 1: create the backend resources
Run the bootstrap helper once:
export AWS_REGION=us-east-1
bash scripts/bootstrap-state.sh
The script creates the S3 bucket and DynamoDB lock table used by the Terraform backend.
Step 2: update the backend block
After the script prints the backend resource names, update the relevant root backend file:
terraform/staging/backend.tfterraform/prod/backend.tf
Each root uses its own state key and its own backend resources.
Step 3: initialize the root
- Staging
- Production
cd terraform/staging
terraform init -migrate-state
cd terraform/prod
terraform init -migrate-state
Current backend layout
| Root | Backend key |
|---|---|
terraform/staging | staging/terraform.tfstate |
terraform/prod | prod/terraform.tfstate |
warning
Do not point both roots to the same backend key. Root separation is part of the environment model, not just a folder naming choice.