codedamn

How to block public access to your S3 bucket?

How to block public access to your S3 bucket?

For some reason, you might want to restrict public access to your S3 bucket.

Don’t worry. I got you covered. In this article, I have shown you how to restrict people from accessing your S3 bucket.

How to block public access when creating a new bucket?

Step 1: Sign in to your AWS account.

Step 2: On the top left search bar, search for the S3 service.

Step 3: Click on the orange Create bucket button.

create bucket
create bucket

Step 4: Fill in the bucket name, and keep it unique.

step 4 to 7
Steps 4 to 7

Step 5: Select the region for your bucket. By default, AWS suggests you the best location.

Step 6: If you already have a predefined bucket, you can select that bucket or move to the Object Ownership section.

Step 7: Inside the Object Ownership section, choose if you want ACL enabled or disabled. 

If enabled, then other amazon AWS accounts can control your bucket. If disabled, then you are the only owner of that bucket. 

Step 8: Now we are into the section of block public access setting into this bucket.

step 8
step 8

In this section, all options are selected by default, but you might want to list all the files using AWS CLI, then deselect the last two options.

Step 9: After that, you can select the bucket versioning and the rest of the options according to your project needs.

Steps 9 and 10
Steps 9 and 10

Step 10: Finally, Click on the orange create a bucket to create a bucket restricting public access to the S3 bucket.

That’s it, and Now your newly created S3 bucket will block public access.

How to block public access to your existing S3 bucket?

Step 1: Sign in to your AWS account

Step 2: Select the S3 service.

Step 3: You will see all your buckets listed. Click on the `bucket` you want to block public access.

Step 4: Inside the bucket dashboard, click on the permission tab

Steps 4 and 5
Steps 4 and 5

Step5: Inside the public access setting section. Click on the `edit` button.

Step 6: Select the options as per your need. 

If you select the first two options,

It will block access to your other AWS amazon accounts, which have access to your bucket, like the sub-authenticated accounts of your group.

If you select the last two options, you will completely block public access to your AWS bucket. But, You can’t list files, folders, or filenames using AWS CLI.

Step 7: That’s it. You can save the changes by clicking on the save changes button.

What will happen if you don’t block public access?

Unchecking all the options is not recommended, and it will be a threat to your S3 bucket. 

Someone might gain access to your S3 bucket and delete the files present inside the bucket.

Summary

I hope you found this article helpful. AWS is known for its strong security and performance. Once you block public access to your s3 bucket, it will be hard for third parties and other groups to access it.

Make sure to use the best security measure for your account, and enable Multi-factor Authentication to your account so third parties can’t access your account.

Learn programming on codedamn

Codedamn is an interactive coding platform with tons of sweet programming courses that can help you land your first coding job. Here's how:

Programming is one of the most in-demand jobs today. Learning to program can change your future. All the best!

Sharing is caring

Did you like what Mujahid Khan H A wrote? Thank them for their work by sharing it on social media.