- Newest
- Most votes
- Most comments
The issue you're experiencing is related to how the s3:ListAllMyBuckets permission is configured in your policy. While you've included this permission, there's a problem with how the resource is specified for this action.
For the s3:ListAllMyBuckets action, you need to specify the resource as * rather than arn:aws:s3:::*. The s3:ListAllMyBuckets action operates at the AWS service level, not at the bucket level, so it requires a different resource specification.
Here's how you should modify the third statement in your policy:
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "*"
}
This change should resolve the "AccessDenied" error you're encountering when trying to list all buckets. The rest of your policy looks correct for allowing access to list the specific bucket and perform object operations within that bucket.
Sources
Bucket policies for Amazon S3 - Amazon Simple Storage Service
Amazon S3: Restrict management to a specific S3 bucket - AWS Identity and Access Management
I think your permissions are getting blocked by SCP or your role has a permission boundary that is blocking the permission. I have tested and the permissions look ok. Also, you can use the policy simulator tool to determine whether the permission are correct.
policy simulator tool :
- https://policysim.aws.amazon.com/home/index.jsp
- https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_testing-policies.html
Policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "*"
}
]
}
Screen shot
If "Permission Boundary" is set on your IAM user then make sure the following policy is attached in your Permission boundary policy as well:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "*"
}
]
}
To check the Permission Boundary policy of your IAM user, Follow below steps on AWS Management Console:
- Open the IAM Console Home page
- In the navigation pane, choose Users.
- In the Users list, choose the name of the IAM user whose permissions boundary you want to Edit/view.
- Choose the Permissions tab. Scroll down and open the Permissions boundary section.
Note: If permission boundary is not set, this section will display the title as "Permissions boundary (not set)"
Relevant content
asked 2 years ago
asked 2 years ago

I already tried to use
"Resource": "*"and I have the same error.