Skip to Content

Lifecycle rules

Moving objects between storage classes, transition and expiration actions, two classic exam scenarios, and Storage Class Analysis.

Moving between storage classes

Objects can move from one storage class to a cheaper one as they age. Transitions go downwards, from hotter to colder classes: from Standard to any other class, from Standard-IA to Intelligent-Tiering, One Zone-IA or the Glacier classes, and so on down to Glacier Deep Archive.

  • For objects read less often, move them to Standard-IA.
  • For archives not needed quickly, move them to Glacier Flexible Retrieval or Glacier Deep Archive.

Classes could be changed by hand, but lifecycle rules do it automatically.

Lifecycle rules

A lifecycle rule over time: objects start in S3 Standard, transition to Standard-IA after 30 days, to Glacier Flexible Retrieval after 180 days, and expire (are deleted) after 365 days A lifecycle rule over time: objects start in S3 Standard, transition to Standard-IA after 30 days, to Glacier Flexible Retrieval after 180 days, and expire (are deleted) after 365 days

One rule that moves objects down, then deletes them.

A lifecycle rule has two kinds of action:

  • Transition actions move objects to another storage class after a number of days. For example: to Standard-IA 60 days after creation, then to Glacier Flexible Retrieval after 6 months.
  • Expiration actions delete objects after some time. For example:
    • delete access log files after 365 days;
    • delete old (noncurrent) versions of objects, if versioning is on;
    • delete incomplete multipart uploads, whose parts are billed but can't be used.

A rule can apply to the whole bucket, to a prefix (such as s3://mybucket/mp3/*), to objects with certain tags (such as Department: Finance), or to objects in a size range.

Things to know:

  • Objects smaller than 128 KB don't transition by default, because each transition is a billed request.
  • Moving objects into a class with a minimum duration (IA, Glacier) before that minimum is up is charged as if they stayed.

Scenario 1: thumbnails and source images

An application on EC2 makes thumbnails of profile photos uploaded to S3. Thumbnails can be re-created at low cost and only need to be kept for 60 days. The source images must be available immediately for 60 days; after that, users can wait up to 6 hours.

  • Source images: S3 Standard, with a lifecycle rule to transition to Glacier Flexible Retrieval after 60 days (Standard retrieval takes 3 to 5 hours).
  • Thumbnails: S3 One Zone-IA (cheap, and they can be re-created), with a rule to expire them after 60 days. Use a prefix or tag so each rule only hits its own objects.

Scenario 2: recovering deleted objects

Deleted S3 objects must be recoverable immediately for 30 days, although this rarely happens. After that, and for up to 365 days, deleted objects must be recoverable within 48 hours.

  • Turn on S3 Versioning, so a "deleted" object is only hidden behind a delete marker and its versions remain.
  • Transition noncurrent versions to Standard-IA (immediate access, cheaper).
  • Then transition noncurrent versions to Glacier Deep Archive (retrieval within 48 hours with Bulk), and expire them after 365 days.

Storage Class Analysis

Storage Class Analysis (part of S3 Analytics) helps decide when to transition objects.

  • It watches how objects are accessed and recommends when to move them from Standard to Standard-IA. It doesn't cover One Zone-IA or Glacier.
  • The report is updated daily, and data starts to appear 24 to 48 hours after it is turned on. It can be exported as a CSV file to a bucket.
  • A good first step for writing (or improving) lifecycle rules.

Real-world examples

  • A media company keeps new videos in Standard, moves them to Standard-IA after 30 days and to Glacier Deep Archive after a year.
  • A team forgets about failed uploads of huge files. A rule that aborts incomplete multipart uploads after 7 days removes gigabytes of hidden, billed parts.
  • A versioned bucket's bill keeps growing. A rule that expires noncurrent versions after 90 days stops it.

Exam tips

  • "Automatically move objects to a cheaper class after N days" → lifecycle transition action.
  • "Delete old log files automatically" → lifecycle expiration action.
  • "Old versions are costing money" → expire noncurrent versions.
  • "Hidden storage cost from failed uploads" → abort incomplete multipart uploads.
  • "Which objects should move to Standard-IA, and when?" → Storage Class Analysis.
  • "Recover deleted objects within 48 hours for a year" → versioning + transition noncurrent versions to Deep Archive.

Common traps

  • "Lifecycle rules move objects from Glacier back to Standard." Transitions only go to colder classes; to bring data back, restore and copy it.
  • "Storage Class Analysis recommends Glacier transitions." Only Standard to Standard-IA.
  • "Expiration actions are free in any class." Expiring before a class's minimum duration still incurs the minimum charge.

Hands-on lab: a lifecycle rule

Goal: create a rule that tiers and expires objects under a prefix, and cleans up old versions and failed uploads.

Costs money

Creating a rule is free. With only a few test objects, any transitions cost less than a cent. Any Region works.

Create the rule

In your versioned lab bucket, Management → Create lifecycle rule. Name logs-tiering, scope Limit the scope with filters, prefix logs/.

Choose the actions

Tick Transition current versions (Standard-IA after 30 days, Glacier Flexible Retrieval after 180 days), Expire current versions after 365 days, Permanently delete noncurrent versions after 30 days, and Delete incomplete multipart uploads after 7 days. Acknowledge the warning about small objects, then create.

Read the timeline

The rule page shows a Review transition and expiration actions timeline: day 0, day 30, day 180, day 365. Upload a test file under logs/; S3 applies the rule in the background (usually once a day).

Expected result: a rule that will move logs/ objects to cheaper classes and delete them after a year, without any code.

Clean up: delete the rule and the test object.

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt