0
0
AWScloud~30 mins

S3 lifecycle rules in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
S3 Lifecycle Rules Setup
📖 Scenario: You manage a cloud storage bucket that holds many files. To save money and keep the storage tidy, you want to automatically move files to cheaper storage after some days and delete old files after a longer time.
🎯 Goal: Create an AWS S3 bucket lifecycle configuration that moves files to the STANDARD_IA storage class after 30 days and deletes files after 365 days.
📋 What You'll Learn
Create a lifecycle rule named exactly ArchiveAndExpireRule
Set the rule to apply to all objects in the bucket
Transition objects to STANDARD_IA storage class after 30 days
Expire (delete) objects after 365 days
Enable the lifecycle rule
💡 Why This Matters
🌍 Real World
S3 lifecycle rules help manage storage costs by automatically moving or deleting files based on age.
💼 Career
Cloud engineers and DevOps professionals use lifecycle rules to optimize storage and reduce expenses.
Progress0 / 4 steps
1
Create the basic lifecycle configuration structure
Create a variable called lifecycle_configuration and assign it a dictionary with a key Rules that holds an empty list.
AWS
Need a hint?

This is the container for all lifecycle rules. Start with an empty list for rules.

2
Add the lifecycle rule configuration dictionary
Add a dictionary to the Rules list inside lifecycle_configuration with the key ID set to "ArchiveAndExpireRule", and Status set to "Enabled".
AWS
Need a hint?

The rule needs a name and must be enabled to work.

3
Add transition and expiration actions to the rule
Inside the rule dictionary in lifecycle_configuration["Rules"], add a Filter key with an empty dictionary, a Transitions key with a list containing a dictionary that sets Days to 30 and StorageClass to "STANDARD_IA", and an Expiration key with a dictionary setting Days to 365.
AWS
Need a hint?

The filter applies to all objects. Transition moves files after 30 days. Expiration deletes after 365 days.

4
Complete the lifecycle configuration for deployment
Ensure the lifecycle_configuration dictionary is fully defined with the Rules list containing the rule dictionary with keys ID, Status, Filter, Transitions, and Expiration as specified. This configuration is ready to be used with AWS SDK or CLI to set the bucket lifecycle.
AWS
Need a hint?

This is the final lifecycle configuration dictionary ready for deployment.