DEV Community

GargeeBhatnagar for AWS Community Builders

Posted on

Lifecycle Rule for Current and Noncurrent Versions in S3 Bucket

“ 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 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
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

Image description

Image description

Image description

Image description

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

Image description

Image description

Image description

Image description

Image description

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. To learn more, read the Amazon S3 documentation.

Thanks for reading!

Connect with me: Linkedin
Image description

Top comments (0)