Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
S3 — Object Storage  ›  Capstone Project

Lifecycle Rules

Bucket / Object Lifecycle 15 minAn S3 lifecycle rule automatically moves objects matching a filter to colder storage classes and deletes them after set ages, so data follows its natural timeline without manual work.

Lifecycle Rules

Inkwell now knows which storage class each invoice should be in, and it changes with age: hot for a month, cool for a year, frozen for years, then gone. Moving thousands of files by hand every month would never actually happen. A lifecycle rule writes that timeline down once and S3 follows it forever.

The rule

Write the timeline once: hot, cool, cold, gone.

A lifecycle rule has three parts:

  • A filter: which objects it applies to, by key prefix, by tags, by object size, or the whole bucket.
  • Transition actions: after N days, move matching objects to a colder class.
  • Expiration actions: after N days, delete them.

Inkwell's rule for invoices:

Filter:      prefix invoices/
Day 30:      transition to S3 Standard-IA
Day 365:     transition to S3 Glacier Deep Archive
Day 2555:    expire (about seven years)

Rules can also clean up two hidden costs:

  • With versioning on, old versions pile up silently. Expire noncurrent versions after, say, 30 days.
  • Large uploads that failed halfway leave invisible parts that are still billed. Abort incomplete multipart uploads after a few days.

Rules of the road:

  • Transitions only flow downhill, to colder classes. No rule moves an object back to Standard; you would restore or copy it yourself.
  • Objects must sit at least 30 days in their current class before a rule can move them to Standard-IA or One Zone-IA.
  • By default, objects smaller than 128 KB are not transitioned, because the move would cost more than it saves.
  • S3 applies rules in the background, so an action may happen a little after the exact day.

The shortcut

Draw the object's life as a timeline of four stops, hot, cool, cold, gone, write the day each stop begins, then translate each stop into one action. Skip any stop the data does not need.

Turning the invoice timeline into a ruleStep 1 of 4
  1. Hot: days 0 to 30

    Customers check recent invoices often. Stay in Standard; no action needed.

The trap is expiring the wrong prefix. An expiration rule with no filter applies to the whole bucket, covers included. Always check the filter before saving.

Drills

Answer fast — trust the rule.

quick drill

What does an expiration action do?

quick drill

Can a lifecycle rule move objects from Glacier Deep Archive back to S3 Standard?

quick drill

Inkwell saves a rule with an expiration at day 90 and no filter. What does it affect?

quick drill

Which rule action removes the hidden cost of half-finished large uploads?

Remember

  • Write the timeline once: hot, cool, cold, gone.
  • Filter, then transitions (downhill only), then expiration; add noncurrent-version and incomplete-upload cleanup.
  • Trap: a rule without a filter touches the whole bucket.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainAutomate the invoices' timeline

Design a lifecycle rule for Inkwell's invoices/ prefix: invoices are read often in their first month, rarely for the rest of the first year, must be kept for seven years in total, and then deleted. Give the filter, each transition with its day number and class, the expiration, and one extra action that keeps the bucket tidy. Explain why the rule cannot move old invoices back to Standard.