©2019 by Raghavendra Kambhampati

How to Create an S3 Bucket, Upload an Object, Create Bucket Policy & Explore Versioning?

Task 1:Create a Bucket

1.In the AWS Management console,on the Services menu, Click S3 under Storage.

2.Click Create Bucket and then enter the values for BucketName (The Value for Bucket name is Unique across all AWS Accounts and Regions) and Select Region where you want to create bucket.->Click Next.

2.Enable Versioning(Enable the Checkbox for Versioning)->Click Next.

3.Deselect all the options ->Click Next->Click Create Bucket.

Task 2:Upload an Object to the Bucket

Now since we created a bucket,we are ready to store objects.An object can be any kind of file:a text file,a photo,a video,a zip file,etc.

1.In the S3 Management Console->Click on your bucket ->Click Upload->Click Add Files->Click Next->Click Next->Click Next->Click Upload.

Task 3:Make Your Object Public

By default,all the newly created buckets and objects inside it are private.To verify this,click the object you uploaded and there appears s3 link displayed at the bottom.Copy that link and paste in the browser and you should be receiving an Access Denied error.This is because objects in Amazon S3 are private by default.

We will now configure the object to be publicly accessible.

1.Go to S3 Management console->Click on your bucket->Select the uploaded object->Click on Actions Menu->Select Make Public.

2.Now copy the S3 Object path again and copy in the browser and you should be seeing the image or file which we uploaded.

In this example,we granted read only access only to specific object.If we want to grant access to an entire bucket,we need to use Bucket Policy.

Task 4:Create a Bucket Policy

Bucket Policy is a set of permissions associated with an Amazon S3 bucket.It can be used to control access to whole bucket or to specific directories within a bucket.

Let’s upload an another file to same bucket and see if we are able to access the file from the browser using the S3 object path.By default,it should not allow access since it is private.Follow the same steps as previously mentioned to verify this.

1.I have uploaded another file,copied the S3 object link and pasted in the browser and received Access Denied error.

So,lets now create a Bucket Policy and apply on the bucket level,by which we should be able to view the file once we run the S3 object link the browser.

2.Go to the Bucket list ->Click on the Permissions Tab->Click on Bucket Policy.

A blank Bucket Policy editor is displayed.Bucket policies can be created manually or they can be created with the help of AWS Policy generator.Before creating the policy,we will need to copy the ARN(Amazon Resource Name) of your bucket.It is displayed at the top of the Bucket Policy editor as arn:aws:s3:::demobucket1987

3.Click the Policy generator at the end of the page->New AWS Policy generator Page opens->Select S3 Bucket policy as the Policy Type->Enter * in Principal field(Anyone will be able to perform actions in the policy) ->Select GetObject in Actions field (GetObject grants permission for objects to be retrieved from Amazon S3)

4.Copy the ARN of the bucket and paste it in the ARN (Amazon Resource Name) field and add /* at the end like –arn:aws:s3:::demobucket1987/*  and then Click Add Statement->Click Generate Policy.

Copy the code and paste in the Bucket Policy editor page->Click Save.

5.Now refresh the S3 Object URL for the new object uploaded ,the file should be displayed.

Task 5:Explore Versioning

Versioning is a means of keeping multiple variants of an object in the same bucket.With versioning we can retrieve,restore every version of object stored in your Amazon S3 bucket.

Let’s click on any one of the image named header.jpg which we uploaded->Click on the Latest Version(It will show the latest version).

2.Upload the same file again to the same S3 bucket ->Click on the S3 object->Click on the Latest Version(You will see 2 versions- Latest and Previous one)

3.Now the header.jpg file will be deleted .Select the Object->Actions->Delete.

Since Versioning is enabled,the moment S3 object is deleted,it is not deleted completely and is marked as Delete marker.(That means we still have the option to retrieve the file back )

As we can see here,I am selecting the latest version of the S3 object file (not the Delete marker one,this is just marked as file ready to delete).Once we select the file we get the option to download the file and hence file can be retrieved.This is how Versioning feature will enable as the backup for all the objects getting stored in S3 ,as it will help us in retrieving your latest file without losing anything.


0 views