Create Lifecycle Rules to Manage Your S3 Files

Ankit Gupta
AWS in Plain English
6 min readSep 14, 2021

--

Hello, everyone. In this blog, I’m going to show you how to use S3 lifecycle rules to automatically transition data in between different tiers on your S3 bucket. This can greatly reduce costs, especially if you have a lot of data that you don’t access very often in your bucket.

pic credit :Ankit Gupta

We are in the S3 console so I pre-created a bucket that has a bunch of files and is interesting for demo purposes in this blog.

pic credit :Ankit Gupta

So we’ve got some random stuff in order to create the lifecycle rule so on a bucket and in order to do that we enter inside the bucket,

pic credit :Ankit Gupta

Then we go to the management tab up here click on management and by default, you’re in the lifecycle rule section.

pic credit :Ankit Gupta

So all you have to do with this point is click on add/create lifecycle rule that fires up a prompt here.

pic credit :Ankit Gupta

In this prompt, this is where we’re gonna specify all the settings for our lifecycle rule, so this is going to be the full lifecycle of an S3 file or a series of files that are within a bucket so let’s go ahead and do that now so we need to create a rule name so let’s call this S3 full lifecycle.

pic credit :Ankit Gupta

And down here, it’s going to ask us to choose a rule scope so if you want to apply this rule to a subset of files within a bucket maybe only those that are within a certain path or a certain folder you can do that by clicking on the first button here limit the scope to a specific prefix and just add the path that you want so say if I had one that was transactions folder or something like that I would just say slash slash transactions and this would tell s3 lifecycle to only commit the rule to the files that are within this this path so we’re not going to do that here for just for simplicity’s sake I’m just going to apply it to all so I can click on this second box here we’re going to go ahead and click on next now so this is where we actually set up the transitions so if you didn’t already know there’s a concept of versioning in S3 so every time you modify a file a version of it gets stored and kind of maintained although the current version is always the one that is retrieved if you’re kind of looking it up by key so if you want to have different rules based on the versions of the file you can set that up it’s pretty easy to do and there’s not much difference than what I’m going to show you now but we’re just gonna do for a current version.

pic credit :Ankit Gupta

Here just to show you as a basic example so I clicked on the tab current version and now we have this second prompt here for current versions of objects I’m just telling us that we don’t have any transitions set up yet so let’s go ahead now and click on add transition and start creating these okay so object creation obviously takes place. So the rule I want to create today is going to be for a full s3 lifecycle so after 30 days I want to move this file to Standard-IA after 60 days I want to move this file to the intelligent tier after 90 days I want to move it to glacier and after 180 days I want to move it to deep glacier Deep Archive.

pic credit :Ankit Gupta

When it’s created and we want to transition into the intelligent tiering is quite a bit cheaper than standard we want to do that after 30 days so after 30 days transition to intelligent and then click on add transition to add a second rule now so we’re gonna go to glacier after 90 days and we also get this nice big warning box here this is just telling us that there’s an additional cost for using glacier it’s just effectively saying that you’re gonna transition a whole bunch of data into the glacier service and there’s an additional cost for that so you can see here it gives you a preview as well since I only have you know three objects in my bucket here my estimate is very low but if you have a big bucket then this may be a little bit different so I’m gonna acknowledge this this is something that you must doing order transition to glacier and the last rule that I set up is we want to go too deep glacier after one year so we’re gonna put in 180 days so that looks good here transition to deep glacier. While so that’s pretty much everything that you need to know at least for setting this up initially go ahead and click on next now and this is just giving us a summary of everything.

pic credit :Ankit Gupta
pic credit :Ankit Gupta

We can see here now in the life cycle section of the management tab that we can see that we have this S3 life cycle rule that’s being applied to the whole bucket we can do a couple of manipulations here we can enable or disable it after you click on it, of course, enable or disable you can also go ahead and edit the settings so if you want to change this to a specific path or kind of modify any of the transition rules you can go ahead and do.

pic credit :Ankit Gupta

I hope this blog helps and saves your precious time and money so that you can spend it with your loved ones. Keep smiling and show some love!

References :

http://d1.awsstatic.com/whitepapers/aws_pricing_overview.pdf

https://aws.amazon.com/s3/pricing/

Author Linkedin :

Other Blogs:

Thank you for reading, if you enjoyed it, please hit the clap button.

Follow us for more content.

Check out AWS in Plain English for more AWS-related content.

More content at plainenglish.io.

--

--