How to make your S3 buckets public

I wrote about how I set up S3 uploads for the job board for developers I created, DEVJOBS.

After I had the S3 bucket ready, and the image was uploaded and then the URL was stored in my database, I realized the image was not accessible publicl…

I wrote about how I set up S3 uploads for the job board for developers I created, DEVJOBS.

After I had the S3 bucket ready, and the image was uploaded and then the URL was stored in my database, I realized the image was not accessible publicly in read mode.

The image was there, but could not be seen by anyone.

If I tried to access it, all I got was something like

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>E5FBYNEYEFNZH</RequestId>
<HostId>
iImqC8XkvmPP4/BJxNGDZrPrDr7us1u3UeZqH8prlv3dk69R9m7uOaaaZDvTLAtne2rLkRWZ4=
</HostId>
</Error>

Ok, I thought, it’s a permission issue.

So first I tried to edit the “Block public access” setting, disabling the block I had:

But this didn’t work. The image was still inaccessible.

So I went and set the Everyone (public access) setting to Read in a single file permission:

and this worked, for the single file.

So I went to the general bucket permissions, which has a similar ACL permissions panel, to set the same thing.

I set Everyone (public access) setting to Read but it didn’t work as expected.

People could not see the files publicly, even though I was setting it explicitly.

Turns out there’s no way to make this through clicking around.

I had to set a Bucket Policy, which can be done from the bucket permissions page, and I added this:

{
  "Version": "2008-10-17",
  "Statement": [
    {
      "Sid": "AllowPublicRead",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::YOURBUCKETNAME/*"
    }
  ]
}

change YOURBUCKETNAME to your bucket name

This made it work. Once you add this, you can set the Block public access as follows:

That’s it. Now my files (images in my case) were accessible from the public.


Print Share Comment Cite Upload Translate
APA
flaviocopes.com | Sciencx (2024-03-29T06:25:09+00:00) » How to make your S3 buckets public. Retrieved from https://www.scien.cx/2021/06/23/how-to-make-your-s3-buckets-public/.
MLA
" » How to make your S3 buckets public." flaviocopes.com | Sciencx - Wednesday June 23, 2021, https://www.scien.cx/2021/06/23/how-to-make-your-s3-buckets-public/
HARVARD
flaviocopes.com | Sciencx Wednesday June 23, 2021 » How to make your S3 buckets public., viewed 2024-03-29T06:25:09+00:00,<https://www.scien.cx/2021/06/23/how-to-make-your-s3-buckets-public/>
VANCOUVER
flaviocopes.com | Sciencx - » How to make your S3 buckets public. [Internet]. [Accessed 2024-03-29T06:25:09+00:00]. Available from: https://www.scien.cx/2021/06/23/how-to-make-your-s3-buckets-public/
CHICAGO
" » How to make your S3 buckets public." flaviocopes.com | Sciencx - Accessed 2024-03-29T06:25:09+00:00. https://www.scien.cx/2021/06/23/how-to-make-your-s3-buckets-public/
IEEE
" » How to make your S3 buckets public." flaviocopes.com | Sciencx [Online]. Available: https://www.scien.cx/2021/06/23/how-to-make-your-s3-buckets-public/. [Accessed: 2024-03-29T06:25:09+00:00]
rf:citation
» How to make your S3 buckets public | flaviocopes.com | Sciencx | https://www.scien.cx/2021/06/23/how-to-make-your-s3-buckets-public/ | 2024-03-29T06:25:09+00:00
https://github.com/addpipe/simple-recorderjs-demo