`An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied` for a user who has S3 read access. What is wrong?
BeginnerTroubleshootingIAM and Access Errors
Answer
Likely causes → The policy grants object actions but not s3:ListAllMyBuckets; or the user is on a different profile than expected.
Diagnose →
aws sts get-caller-identity
aws iam list-attached-user-policies --user-name alice
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111111111111:user/alice --action-names s3:ListAllMyBuckets
Fix →
- Confirm you are using the intended profile with
AWS_PROFILE - Add
s3:ListAllMyBucketson*if bucket listing is genuinely required - Otherwise instruct the user to
aws s3 ls s3://bucketdirectly
Prevent → Document the minimal policy template for S3 users; bucket-scoped listing needs s3:ListBucket on the bucket ARN.
More on IAM and Access Errors
`ExpiredToken: The security token included in the request is expired` in a long CI job. How do you fix it?Beginner`User: arn:aws:sts::111111111111:assumed-role/dev/bob is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::222222222222:role/deploy`. Why?Intermediate`An error occurred (AccessDenied) ... because no identity-based policy allows the s3:GetObject action` yet a bucket policy allows the user. Cross-account?IntermediateIAM policy validation: `MalformedPolicyDocument: Policy document should not specify a principal`. What happened?Intermediate`The security token included in the request is invalid` when using `aws` CLI.BeginnerSSO login works in the browser but `aws sso login` hangs or gives `Error loading SSO Token: Token for ... does not exist`.Intermediate