`Unable to list objects in S3 bucket "acme-tfstate" with prefix "env:/": operation error S3: ListObjectsV2, https response error StatusCode: 403`.
IntermediateTroubleshootingState Locking and Backend Errors
Answer
Likely causes → The role can read/write the state object but lacks s3:ListBucket on the bucket. Terraform lists env:/ to discover workspaces during init.
Diagnose →
aws s3api list-objects-v2 --bucket acme-tfstate --prefix env:/ --max-items 1
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111122223333:role/tf-ci \
--action-names s3:ListBucket --resource-arns arn:aws:s3:::acme-tfstate
Fix → Grant s3:ListBucket on arn:aws:s3:::acme-tfstate (optionally conditioned on s3:prefix), plus s3:GetObject/s3:PutObject on the key, and s3:DeleteObject for .tflock if using native locking.
Prevent → Keep a tested least-privilege backend policy as a module and attach it to every Terraform role.
More on State Locking and Backend Errors
`terraform plan` fails with `Error acquiring the state lock` and `ConditionalCheckFailedException: The conditional request failed`.BeginnerWith the S3 backend and `use_lockfile = true`, you get `Error acquiring the state lock` with `StatusCode: 412` and `PreconditionFailed`.Intermediate`terraform force-unlock` returns `Failed to unlock state: lock ID "..." does not match existing lock`.BeginnerA teammate ran `terraform apply -lock=false` "because the lock was stuck". Now the plan shows resources you never touched being recreated.Advanced`terraform init` fails with `Error: Backend configuration changed`.Beginner`terraform init -migrate-state` asks `Do you want to copy existing state to the new backend?` and the new backend already has a state. What is the danger?Intermediate