An error occurred (AccessDenied) when calling the PutBucketPolicy operation: Access Denied

0

Hello,

aws CLI : aws s3api put-bucket-policy --bucket compty08052023 --policy file://public-access-policy.json

An error occurred (AccessDenied) when calling the PutBucketPolicy operation: Access Denied

AmazonS3FullAccess AWS managed Directly i also tried AdministratorAccess and even to create policy like : { "Version": "2012-10-17", "Statement": [ { "Sid": "S3BucketManagement", "Effect": "Allow", "Action": [ "s3:CreateBucket", "s3:DeleteBucket", "s3:ListAllMyBuckets" ], "Resource": "" }, { "Sid": "S3BucketPolicyManagement", "Effect": "Allow", "Action": [ "s3:PutBucketPolicy", "s3:GetBucketPolicy", "s3:DeleteBucketPolicy" ], "Resource": "arn:aws:s3:::" } ] } but nothing worked. Don t know what to do.

1 Answer
0

Hello,

When I have seen Access Denied like this, it's the credentials that you are using to perform the operation and not what the policy looks like. Based on the example above you are using the default user credentials for your CLI on the host that you are using. I say that because there is no --profile option to the CLI statement above. So what access does the account that you are using have? In the documentation https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketPolicy.html. it states.

If you don't have PutBucketPolicy permissions, Amazon S3 returns a 403 Access Denied error.

Which is what you are receiving when making the call. If that's the issue, you only need to grant the account that you are using PutBucketPolicy right, or something more general like PowerUser

profile pictureAWS
answered a year ago
profile picture
EXPERT
reviewed 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions