Free — no signup required

Lifecycle Policies: Automating the Flow

2 min read

You should almost never move objects between storage classes manually. Instead, you define Lifecycle Policies — rules that S3 executes automatically on your behalf.

The Data Waterfall Mental Model

Think of your data as water flowing downhill over time. Fresh data starts at the top (S3 Standard, expensive, fast). As it ages and is accessed less frequently, it flows down through cheaper tiers, and eventually drains away (expires/deletes). A Lifecycle Policy is the system of channels and gates that controls this flow.

A policy is a JSON or XML document attached to a bucket. It contains two types of rules:

  • Transition Actions: "Move objects with the prefix logs/ to Standard-IA after 30 days. Move them to Glacier Deep Archive after 365 days."
  • Expiration Actions: "Delete objects with the prefix temp/ after 7 days." or "Delete objects after 7 years."

A Concrete Example

A common pattern for application logs:

Day 030:   S3 Standard         (engineers actively query recent logs)
Day 3090:  S3 Standard-IA      (logs are rarely queried, kept for debugging)
Day 90365: S3 Glacier Flexible (compliance retention, almost never accessed)
Day 365+:   Expired (deleted)   (retention period ends)

This single policy, applied once, runs forever without human intervention. It ensures you never pay Standard prices for year-old logs.

Important constraint: You cannot transition objects backward up the hierarchy (e.g., from Glacier back to Standard) via a Lifecycle Policy. Restoring from Glacier is a separate, manual or programmatic operation. Lifecycle Policies only move data down the cost hierarchy.

This is one of 18 chapters

Get every chapter — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

See pricing