Xi 张熹
Xi 张熹

Reputation: 11071

Cannot set bucket policy of amazon s3

I was simply following the "get started" tutorial here

But I failed at "Step 4 Add a Bucket Policy to Allow Public Reads". It always complains "access denied" with a red error icon.

I am not able to set it via command line either. Here is the command I use:

aws s3api put-bucket-policy --bucket bucket-name --policy file://bucket-policy.json

Here is the error I got:

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

Upvotes: 1

Views: 3669

Answers (2)

AleXoundOS
AleXoundOS

Reputation: 446

When creating a new bucket, default policy doesn't grant public access (Amazon S3 Block Public Access is enabled). If your new bucket policy grants public access, you need to run this at first for existing bucket:

aws s3api delete-public-access-block --bucket ${BUCKET_NAME}

Upvotes: 4

Xi 张熹
Xi 张熹

Reputation: 11071

The issue was, you have to uncheck the boxes under permissions -> public access settings. Amazon failed to mention this in their tutorial. Bad tutorial.

Upvotes: 11

Related Questions