Skip to content
Tutorials Center
My learning

Topics

Lesson 24 of 70 ยท Storage with S3

Storage Classes and Lifecycle Rules

Compare S3 Standard, Infrequent Access, Glacier and Intelligent-Tiering, automate transitions and expiry with lifecycle rules, and learn how versioning changes the cost picture.

Not all data deserves the same price. A photo uploaded yesterday may be viewed a hundred times today, while a log file from last year is probably read once, if ever. S3 lets you pay less for data you touch rarely by choosing a storage class per object, and lifecycle rules move objects between classes, or delete them, automatically as they age.

This lesson explains the classes and their trade-offs, shows how lifecycle configuration looks, and then lets you run a small rule engine and a versioning model in Python. Prices in the examples are rounded, illustrative numbers chosen to show the shape of the trade-off; real prices differ by Region and change over time, so always check the S3 pricing page for your Region. Real lifecycle configuration cannot run on this site, so the JSON and CLI below are read-only.

The storage classes

All S3 classes offer the same eleven-nines durability design target. They differ in availability, minimum storage duration, retrieval charges and speed, and price per GB-month.

Class Good for Retrieval Notes
Standard Frequently accessed data Milliseconds Highest storage price, no retrieval fee, no minimums
Intelligent-Tiering Unknown or changing access patterns Milliseconds (frequent, infrequent and archive instant tiers) Moves objects automatically; small monitoring fee per object; no retrieval fee
Standard-IA Rarely accessed but needed quickly Milliseconds Lower storage price, per-GB retrieval fee, 30-day minimum, 128 KB minimum billable size
One Zone-IA Re-creatable, infrequent data Milliseconds Stored in a single Availability Zone, so lost if that AZ is destroyed
Glacier Instant Retrieval Archives read a few times a year Milliseconds 90-day minimum
Glacier Flexible Retrieval Archives, backups Minutes to hours 90-day minimum, restore request needed
Glacier Deep Archive Compliance, long-term retention Hours (typically up to 12 to 48) Cheapest, 180-day minimum

There is also S3 Express One Zone, a high-performance class with single-digit-millisecond latency for latency-sensitive workloads. It uses a different bucket type (directory buckets) and is outside the lifecycle rules discussed here.

Two billing rules catch beginners. First, the minimum storage duration: if you delete or move an object out of Standard-IA after 10 days, you still pay for 30. Second, small objects in the infrequent-access classes are billed as if they were at least 128 KB, so a bucket of millions of tiny files can cost more in Standard-IA than in Standard.

Intelligent-Tiering removes the guesswork. It watches each object: after 30 days without access it moves to an infrequent tier, after 90 days to an archive instant tier, and each access moves it back to the frequent tier. Optional archive tiers (reached after 90 or more, and 180 or more, days without access) are cheaper still but need a restore. You pay a monitoring and automation fee per 1,000 objects, objects below 128 KB are not tiered, and there are no retrieval charges. It is a safe default when you cannot predict access.

Lifecycle rules

A lifecycle configuration is a set of rules, each with a filter (prefix, tags, object size) and actions:

  • Transition current objects to another class after N days since creation.
  • Expire current objects after N days. In a versioned bucket, expiring a current object adds a delete marker rather than removing data.
  • Noncurrent version actions: transition or permanently delete old versions N days after they stopped being current, optionally keeping the newest few.
  • Abort incomplete multipart uploads after N days, which removes forgotten parts that otherwise cost money.
  • Remove expired delete markers that no longer hide any versions.
JSON
{
  "Rules": [
    {
      "ID": "age-out-logs",
      "Status": "Enabled",
      "Filter": { "Prefix": "logs/" },
      "Transitions": [
        { "Days": 30, "StorageClass": "STANDARD_IA" },
        { "Days": 90, "StorageClass": "GLACIER_IR" }
      ],
      "Expiration": { "Days": 365 },
      "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
    }
  ]
}
Terminal
aws s3api put-bucket-lifecycle-configuration \
  --bucket acme-prod-logs \
  --lifecycle-configuration file://lifecycle.json

Some limits shape the design. Objects must be at least 30 days old before a rule moves them from Standard to Standard-IA or One Zone-IA, though you can move to Intelligent-Tiering or any Glacier class at any time. Transitions go "down" a waterfall (Standard, then IA, then Glacier tiers), not back up; to get cold data back you restore or copy it. Lifecycle actions run asynchronously, typically once a day at midnight UTC, so an object does not change class at the exact hour you expect. There are also transition request fees, so moving billions of tiny objects can cost more than it saves.

flowchart LR
    S["Standard"] -->|"30 days"| I["Standard-IA"]
    I -->|"90 days"| G["Glacier Instant Retrieval"]
    G -->|"180 days"| D["Deep Archive"]
    D -->|"expiration"| X["Deleted"]

A typical lifecycle waterfall: objects only move toward colder, cheaper classes and finally expire.

A rule engine you can run

The stand-in below applies a rule to objects of different ages and prices a year of storage with and without it. The prices are illustrative per-GB-month numbers. The engine also refuses a transition to Standard-IA before day 30, like the real service.

Python Lifecycle rules and a year of storage cost

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The saving for the logs is partly the transitions and partly the expiry, which is the biggest lever: data you delete is free. For the archive data, Deep Archive makes storage cheap but you would wait hours to read it back, so match the class to how the data is really used.

Versioning

Versioning keeps every version of an object under the same key, each with a version ID. It protects against accidental overwrites and deletes. Once enabled on a bucket, it can be suspended but never fully turned off.

  • A PUT to an existing key creates a new current version; the old one becomes noncurrent but is still stored, and you still pay for it.
  • A plain DELETE does not remove data. It adds a delete marker, a zero-byte placeholder that becomes the current version, so a normal GET returns "not found" while older versions remain recoverable.
  • A DELETE that names a specific version ID permanently removes that version.

Versioning therefore multiplies storage cost for frequently updated objects, which is why lifecycle rules for noncurrent versions matter: for example, delete noncurrent versions 30 days after they become noncurrent while keeping the three most recent. S3 Security shows how Object Lock and MFA delete protect versions from tampering.

Python Versioning, delete markers and noncurrent expiry

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The real lifecycle clock for noncurrent versions starts when a version stops being current, not when it was created, which is exactly what the model does with noncurrent_since.

Choosing a class

A rough decision process works well in practice:

  1. Is the access pattern unknown or erratic? Use Intelligent-Tiering.
  2. Is the data accessed less than about once a month and larger than 128 KB? Standard-IA may pay off after 30 days.
  3. Is it archival and rarely read? Pick a Glacier class based on how long you can wait for a restore.
  4. Is it reproducible (thumbnails, caches)? One Zone-IA is acceptable.
  5. Always add a rule to abort incomplete multipart uploads, and expire what you no longer need.

Use S3 Storage Lens and the storage class analysis to see real access patterns before committing to a rule, and remember the broader cost picture in Cost Management and Optimization.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. You delete a Standard-IA object after 12 days. What do you pay for?

    Standard-IA has a 30-day minimum storage duration, so early deletion is billed as if the object stayed for 30 days.
  2. 2. Which class fits data whose access pattern you cannot predict, with no retrieval fees?

    Intelligent-Tiering moves objects between tiers based on observed access and has no retrieval charges, at the price of a small per-object monitoring fee.
  3. 3. In a versioned bucket, what does a plain DELETE (no version ID) do?

    A plain delete only inserts a delete marker as the current version. You can recover the object by removing the marker or reading an older version ID.
  4. 4. A lifecycle rule tries to move objects to Standard-IA after 7 days. What happens?

    A transition from Standard to Standard-IA or One Zone-IA requires a minimum of 30 days since creation.

Summary

  • Classes trade storage price against retrieval cost, retrieval speed and minimum duration; durability is the same.
  • Intelligent-Tiering automates tiering when access is unpredictable; Glacier classes suit archives.
  • Lifecycle rules transition, expire, clean noncurrent versions and abort stale multipart uploads, all asynchronously.
  • Versioning keeps old versions and uses delete markers; pair it with noncurrent-version expiry.
  • Check minimum durations and the 128 KB minimum billable size before moving many small objects.

Next: S3 Security.