Setting bucket Permissions in S3 - Hands On
Tags: aws, devops, beginners, tutorial
Published: 2021-07-19 05:55:07

Lets see how to set permissions on our S3 bucket and then we will see the affects of the policy on our S3 bucket.


* Upload a few files in S3 bucket.
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/05971bq0gjcsmq67covf.png)
* Go to the bucket homepage and click on permissions.
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eajp7hikzfaic8i76hpf.png)
* In the permissions got to the bucket policy section and click edit.
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q61dt6e8n5pbvtrezvt9.png)
* This takes us to a section where we edit our policies.
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bfhl380xkowt8dpxl3fd.png)
* This is our first time generating our policy. So, lets use the policy generator given by Amazon to make our policy. To use AWS policy generator click policy generator button.
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y3s2t7elybylz9wbw2ea.png)
* AWS policy generator generates policy many different things so select bucket policy from the type of policy.

* In this policy we will make our bucket objects public. So that anyone can see them via the url. To do that we set the following on policy generator.
  * Effect: Allow - This means who ever falls in this policy will be allowed to do the action defined in the bucket policy.
  * Principal: * - This means we ale allowing everyone to action defined in the policy
  * Actions: GetObject - This will allow us to set policy for getting the objects from S3 bucket.
  * Amazon Resource Name (ARN): Bucket ARN get that from the page where we clicked policy generator and add /*
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8l7r81nj6tbog0sgrop7.png)
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8ddx6ysq5k6aaabt3d1.png)


* Click add statement and after that click on generate policy. A policy is generated.
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mdyhsnrg3ykcsbb9a7xt.png)

* Copy this policy and paste it in the edit policy section and click on save changes this will not allow you to save the changes still. 
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vcvbl0nwft1kfxk7przq.png)

* This is because there is a block all public access section in our permissions tab. Edit that and allow all public access by unchecking block all public access. 
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aip40r4ccy6zo326g2e8.png)![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vjc07wduq2r48cvyw14h.png)
* Now you can save you policy. 
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hfpbwhcfro4zl80d9k7.png)
* We have changed the bucket policy. Now click on an object in the bucket and click on the URL given it should open it.
![S3 permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/823iw024xkksnpu7gn5e.png)


So we have changed the S3 bucket policy. We will set other policies and how they affect our bucket later on. Next we will study how to host static sites on S3.