Lifecycle Rule for Current and Noncurrent Versions in S3 Bucket
Tags: aws, amazons3, lifecyclerule, versioning
Published: 2023-10-21 11:55:24

“ I have checked the documents of AWS to create lifecycle rule for current version objects and noncurrent version objects in s3 bucket. In terms of cost, need to pay the cost of the S3 bucket storage charges.”

An S3 Lifecycle configuration is an XML file that consists of a set of rules with predefined actions that you want Amazon S3 to perform on objects during their lifetime. You can also configure the lifecycle by using the Amazon S3 console, REST API, AWS SDKs and the AWS Command Line Interface (AWS CLI).

Amazon S3 Lifecycle configuration rules run once a day. Check and confirm whether the rule has transitioned the storage class. The total number of objects in the bucket affects the time it takes for you to see the change in storage class.

An S3 Lifecycle configuration can have up to 1,000 rules. This limit is not adjustable. The <ID> element uniquely identifies a rule. ID length is limited to 255 characters.

In this post, you will experience the creation of lifecycle rule for current version objects and non current objects with delete marker rule. Here I have created an s3 bucket with bucket versioning enabled and objects in the bucket with version ID.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/in9zezun1pgotnsea7qh.jpg)
The architecture diagram shows the overall deployment architecture with data flow and amazon s3 bucket.

#Solution overview
The blog post consists of the following phases:
1. Create of Amazon S3 Bucket with Bucket Versioning Enabled
2. Create of Lifecycle Rules in Amazon S3 Bucket

##Phase 1: Create of Amazon S3 Bucket with Bucket Versioning Enabled 
1. Open the console of S3, create a bucket named “test-lc-one” with bucket versioning enabled. Upload of objects in bucket and showcase of versioned objects in bucket.

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

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

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

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

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

##Phase 2: Create of Lifecycle Rules in Amazon S3 Bucket
1. Open the console of S3, create a lifecycle rules as objects expire (noncurrent versions) after 1 day in the bucket. Also create a lifecycle rule for delete markers to delete expired objects and to delete incomplete multipart uploads.

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

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

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

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

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

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

#Clean-up
Delete of S3 bucket.

#Pricing
I review the pricing and estimated cost of this example. 
Cost of Amazon S3 = $0.009
Total Cost = $0.009

#Summary
In this post, I showed “how to create lifecycle rule for current and noncurrent versions in s3 bucket”.

For more details on Amazon S3, Checkout Get started Amazon S3, open the [Amazon S3 console](https://s3.console.aws.amazon.com/s3/get-started?region=us-east-1). To learn more, read the [Amazon S3 documentation](https://docs.aws.amazon.com/s3/?icmpid=docs_homepage_featuredsvcs).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)