SAA-C03 Intermediate 25 min

S3 Lifecycle Policies and Storage Cost Control

Simulate data aging with storage classes: create a lifecycle rule that transitions and expires objects, verify tiering, and analyze costs with Storage Lens — the core of cost-optimized storage design.

Amazon S3S3 Storage ClassesLifecycle RulesS3 Storage Lens
Progress: 0 / 6 steps
Step 1
Create a Bucket and Upload Test Objects

1. S3 → Create bucket: yourname-lifecycle-lab (Block public access ON)
2. Upload 3-5 files of any size (or generate with the CLI below)
3. Note the default storage class: Standard

bash
# Optional: create 5 test files of ~1 MB each and upload
for i in 1 2 3 4 5; do
  dd if=/dev/urandom of=test-$i.bin bs=1m count=1
done
aws s3 cp . s3://yourname-lifecycle-lab/ --recursive --exclude "*" --include "test-*"
Tip: Every object lists its storage class under Properties → or via the ListObjectsV2 API.
Step 2
Add a Lifecycle Transition Rule

1. Bucket → Management tab → Create lifecycle rule
2. Name: age-based-tiering, Scope: whole bucket
3. Actions: "Transition current versions of objects between storage classes"
4. Add transition: Standard → Standard-IA after 30 days
5. Add transition: Standard-IA → Glacier Instant Retrieval after 90 days
6. Add transition: Glacier IR → Deep Archive after 365 days
7. Create rule

Tip: Transitions can chain — each rule can carry multiple transitions and an expiration. This single rule is the exam-standard lifecycle answer.
Step 3
Add an Expiration Rule for Prefixes

1. Create a second lifecycle rule: name expire-temp, scope by prefix: temp/
2. Action: "Expire current versions of objects" after 7 days
3. Upload an object to temp/ (e.g., temp/junk.log)
4. Check Management tab → both rules now listed

Tip: Prefix-scoped rules let you treat logs, temp uploads, and archives differently in the same bucket — a common scenario requirement.
Step 4
Simulate and Verify with Storage Class Analysis

1. Upload a few MB to temp/ and to the root
2. Bucket → Metrics tab → review Storage class analysis
3. Open S3 Storage Lens (account level) → Free plan dashboard
4. Identify: total storage, objects by storage class, and the "noncurrent" object count

Tip: Storage Lens free tier shows where bytes live — the first place to look when asked "why is our S3 bill high?".
Step 5
Inspect Object-Level Details (CLI)

Query the storage class of your objects directly:

bash
aws s3api list-objects-v2 --bucket yourname-lifecycle-lab \
  --query "Contents[].[Key,StorageClass,Size]" --output table
Tip: Fresh uploads always start in Standard (or whatever upload header you set); lifecycle transitions happen on schedule (typically within 48h of the threshold).
Step 6
Clean Up

1. Delete all objects (select all → Delete, type permanently delete)
2. Delete the lifecycle rules (Management → select rule → Delete)
3. Delete the bucket

Tip: Deep Archive objects incur minimum 180-day storage charges — never send lab data to Deep Archive unless you mean it.