0
0
AWScloud~30 mins

S3 storage classes (Standard, IA, Glacier) in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
S3 Storage Classes Setup
📖 Scenario: You work for a company that needs to store files in Amazon S3. Different files have different access needs. Some files are used often, some are accessed less, and some are archived for long-term storage.You will create an S3 bucket and configure three folders with different storage classes: Standard, Infrequent Access (IA), and Glacier.
🎯 Goal: Create an S3 bucket named company-files. Inside it, create three folders named standard/, infrequent-access/, and glacier/. Configure lifecycle rules so that files in infrequent-access/ move to the IA storage class after 30 days, and files in glacier/ move to Glacier storage class after 60 days.
📋 What You'll Learn
Create an S3 bucket named company-files
Create three folders: standard/, infrequent-access/, glacier/
Add a lifecycle rule to transition files in infrequent-access/ to IA after 30 days
Add a lifecycle rule to transition files in glacier/ to Glacier after 60 days
💡 Why This Matters
🌍 Real World
Companies use different S3 storage classes to save money by storing less-used files in cheaper storage and frequently accessed files in faster storage.
💼 Career
Cloud engineers and DevOps professionals often configure S3 lifecycle policies to optimize storage costs and data management.
Progress0 / 4 steps
1
Create the S3 bucket and folders
Create an S3 bucket named company-files. Inside the bucket, create three folders named standard/, infrequent-access/, and glacier/.
AWS
Need a hint?

Use aws_s3_bucket to create the bucket. Use aws_s3_bucket_object with empty content to create folders by specifying keys ending with a slash.

2
Add lifecycle configuration variable
Create a variable called lifecycle_rules that will hold the lifecycle rules for the bucket. Initialize it as an empty list for now.
AWS
Need a hint?

Use a Terraform variable block named lifecycle_rules with type list and default empty list.

3
Add lifecycle rules for IA and Glacier folders
Update the lifecycle_rules variable to include two rules: one that transitions objects with prefix infrequent-access/ to storage class STANDARD_IA after 30 days, and another that transitions objects with prefix glacier/ to storage class GLACIER after 60 days.
AWS
Need a hint?

Use a list of maps with keys id, enabled, prefix, and transition containing days and storage_class.

4
Attach lifecycle rules to the S3 bucket
Add a lifecycle_rule block inside the aws_s3_bucket resource named company_files. Use a for_each to loop over the var.lifecycle_rules variable and create lifecycle rules accordingly.
AWS
Need a hint?

Use for_each inside lifecycle_rule to loop over var.lifecycle_rules. Use each.value to access rule properties.