Interview Prep/Terraform/State Locking and Backend Errors

`Error: Failed to get existing workspaces: ... StatusCode: 301 ... requested bucket from "us-east-1", actual location "ap-south-1"`.

BeginnerTroubleshootingState Locking and Backend Errors
Answer

Likely causes → The backend region doesn't match the bucket's region. The backend region is independent of the provider region.

Diagnose → aws s3api get-bucket-location --bucket acme-tfstate

Fix → Set region = "ap-south-1" in the backend config and run terraform init -reconfigure.

Prevent → Keep the state bucket region in the shared backends/*.hcl files, not inferred from AWS_REGION.

All Terraform questions Roadmap: Terraform in production

More on State Locking and Backend Errors