DEV Community

Xi
Xi

Posted on

Make AWS S3 bucket public accessible

Introduction

When you use AWS S3 for the first time, you may encounter access deny issues.
This issue occurs when you open the object URL in the browser.

image

The two most likely causes of this problem are the following.

  1. Amazon S3 Block Public Access is disabled
  2. The bucket policy denies public visit

Here is how to solve this problem.

Solve problem

1. Unchecking "block all public access"

(a). Goto permissions tab in your bucket and click edit in the block public access section

image

(b). Make sure "block all public access" is off

image

2. Apply a new bucket policy to your bucket

(a). Click edit in the bucket policy section

image

(b). Add the following bucket policy to your bucket

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "{Bucket-ARN}/*",
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

(Remember to change {Bucket-ARN} to your own.)

Success

After these two steps, you may notice an additional “Publicly accessible” icon under your bucket.

When we open the object URL in the browser, we will see that it is now accessible properly.

image

Top comments (0)