AWS-S3 Bucket creation access and Life cycle policy
Tags: linux, devops, aws, s3bucket
Published: 2023-11-30 17:58:39

Amazon S3 to store and retrieve any amount of data at any time, from anywhere.An object consists of a file and optionally any metadata that describes that file.

- Amazon S3 is object storage built to store and retrieve any amount of data from anywhere. S3 is a simple storage service that offers industry leading durability, availability, performance, security, and virtually unlimited scalability at very low costs.

- You can create up to 100 buckets in each of your AWS cloud accounts,If needed, you can request up to 1,000 more buckets by submitting a service limit increase.

- Lets see how to creat  a S3 Bucket and upload file.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3aksi7sgg2xh684wtf07.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vb4dw81bjp6qwdlolypb.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/03jhktbvzzyyzhgh71b6.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6ik0xg5n251589x8pe7.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qnaocqq7gnxfqd1av5c.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0atyjry2768ixeu1yv19.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i028rktirwvznwdjxl9g.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vi9d7fkkwgwh0ab6ytb.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qg4at7xdxu8icyq5ic3f.png)
-On the above we have seen to view the upload files via presigned URL.

- Another way to view the files 
select the file > permissions > Uncheck block all public access.

- Bucket policy > edit bucket policy >Policy generator.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k41bvq5yvhkgutk9xbny.png)

- Open as new tab to generate policy, we have select the s3 bucket policy followed by "Get Object" and copy the Amazon Resource Name(ARN) from the uploaded file.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a4g7nn9dqk3kbude5u3v.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iyrg2gqk846s92fimj8x.png)

- Once policy generated copy the policy and paste on the Bucket policy >policy >save.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4ci1e9i01duh93he9u8.png)

- Via file "object URL" You can access the file on public.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1cm0zm7papnyhvaxu5o.png)

- AWS S3 Object storage classes, by default comes with "Standard" you can modify via Action >Edit storage class.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vvrd5l4u2oegm9c5qfd3.png)
  

- If you modified the local file and uploaded to S3 you want version basis need to enable "Bucket versioning"
Properties > Bucket versioning >Edit.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u96edjyqrqj9k84pwxtx.png)

- Once you enabled the versioning able suspend (not to disable)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/euvmjocn98kvw5duq4h6.png)

- the file1.txt was edited locally and uploaded to S3 bucket to see the versioning.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x0zomb67j7wpafrpuc9v.png)

## Life cycle rule

- A lifecycle policy consists of one or more rules that determine which images in a repository should be expired.

- Lifecycle policies help manage and automate the life of your objects within S3, preventing you from leaving data unnecessarily available. They make it possible to select cheaper storage options if your data needs to be retained, while at the same time, adopting additional security control from Glacier.

1. Click on your bucket.
2. Click on Management tab.
3. Click on Create lifecycle rule.
4. First, give a name for the rule.
5. Then choose a rule scope. ...
6. If you choose to apply the rule to all objects then choose “Apply to all objects in the bucket”. ...
7. You can specify the transition for each option.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ryn0xiyxvxz9q06lq8sx.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h44ld59ch6q2hul1b4u3.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hrj7v0pz3mejfs7cak92.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kj1ynaar0o8x4ndqrsjs.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/164gr92h4wsqg6u1x3kk.png)