Issue
Iam new to AWS and now Iam facing the access denied problem when excuted
aws s3api list-objects --bucket BUCKET_NAME
- IAM role: attach AmazonS3FullAccess policy
- EC2: attach above IAM role
- Bucket:
- Block all public access: OFF
- Policy: allow all action
- ACL: OFF
- Other setting: default
IAM Role policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:*",
"s3-object-lambda:*"
],
"Resource": "*"
}
]
}
Bucket Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllActionsForUsersWhoCanList",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::BUCKET_NAME/*",
"arn:aws:s3:::BUCKET_NAME"
]
}
]
}
Solution
After trying numerous solutions, I finally realized that the problem was with my VPC endpoint to S3. There was a policy limiting access to resources. I want to express special thanks to John Rotenstein, who provided me with a lot of advice
Answered By - Shin622 Answer Checked By - Mildred Charles (WPSolving Admin)