Amazon Simple Storage Service (Amazon S3)

AWS S3 Basic Features

Demo Lifecycle Policies

In this walkthrough, you’ll learn how to automate object transitions and expirations in an Amazon S3 bucket using lifecycle policies. We’ll cover:

  • Creating a demo bucket
  • Uploading sample objects
  • Defining lifecycle rules to transition and expire objects across storage classes

Why Use Lifecycle Policies

Lifecycle policies help optimize storage costs by automatically moving objects to lower-cost classes (e.g., Standard-IA, Glacier) or deleting them when they’re no longer needed.

Lifecycle Storage Classes Overview

Storage ClassDescriptionTypical Use Case
S3 StandardFrequent access, low latencyActive datasets
S3 Standard-IAInfrequent access, lower costBackups and long-term storage
S3 Glacier Instant RetrievalMillisecond access retrieval from GlacierArchives with occasional retrieval
S3 Glacier Deep ArchiveLowest cost, hours-long retrieval timeCompliance archives, long-term retention

1. Create a Demo Bucket and Upload Objects

  1. Open the AWS Management Console and navigate to S3.
  2. Click Create bucket, accept all defaults, and finish the wizard.
  3. In your new bucket, click Upload, then drag and drop a few test files and folders. Any sample data will do.

The image shows an AWS S3 upload interface on the left and a Windows File Explorer window on the right, displaying a list of files and folders.

  1. Open Properties for the bucket and confirm that the Storage class of your objects is Standard.

2. Configure Lifecycle Rules

Navigate to the Management tab of your bucket and click Create lifecycle rule.

The image shows an AWS S3 Management Console screen where lifecycle rules for objects are being configured, including options for filtering by prefix and object size, and setting lifecycle rule actions.

You can define multiple rules to target different prefixes (logs/, media/) or object sizes.

2.1 Rule 1: lifecycle-logs

  1. Rule name: lifecycle-logs
  2. Under Scope, select Limit the scope to specific prefixes or tags and enter:
    • Prefix: logs/
  3. (Optional) Specify Minimum size or Maximum size filters.

Current Version Transitions

  • After 30 days: transition to S3 Standard-IA
  • After 60 days: transition to S3 Glacier Instant Retrieval

The image shows an AWS S3 Management Console screen where lifecycle rules for transitioning object storage classes are being configured. It includes options for moving current versions of objects and setting transition actions after a specified number of days.

Non-Current Version Transitions

  • After 30 days: transition to S3 Standard-IA
  • After 90 days: transition to S3 Glacier Deep Archive

The image shows an AWS S3 management console screen where a lifecycle rule is being configured, including transitions to different storage classes and expiration actions for current and noncurrent object versions.

Click Create to save lifecycle-logs.

2.2 Rule 2: lifecycle-media

  1. Rule name: lifecycle-media
  2. Scope → Prefix: media/
  3. Current version transitions:
    • After 60 days: transition to S3 Standard-IA
  4. Non-current version actions:
    • After 30 days: transition to S3 Standard-IA
    • After 365 days: Expire non-current versions

Click Create to save lifecycle-media.


3. Review Your Lifecycle Configuration

Once both rules are enabled, the Lifecycle configuration page displays all active rules:

The image shows the Amazon S3 Management Console with a "Lifecycle configuration" page, displaying two lifecycle rules named "lifecycle-logs" and "lifecycle-media," both enabled.

Propagation Delay

It can take up to 24 hours for lifecycle policies to appear in the billing report and start transitions.


Additional Resources

Watch Video

Watch video content

Practice Lab

Practice lab

Previous
Lifecycle Policies