Skip to main content

Lifecycle Configuration

Intro

The Lifecycle Configuration is used to configure the lifecycle of your objects so they are stored cost-effectively. Currently, only NoncurrentVersionExpiration is supported in Lifecycle Configuration management.

The following APIs can be used for setting, retrieving, and deleting the configuration:

  • PutBucketLifecycleConfiguration: used for setting the configuration, which will override the existing one if present.
  • GetBucketLifecycleConfiguration: used for retrieving the currently configured Lifecycle Configuration.
  • DeleteBucketLifecycle: used for deleting the currently configured Lifecycle Configuration.

The NoncurrentVersionExpiration rule

The NoncurrentVersionExpiration rule is used to delete object versions that exceed the number of versions to keep, as defined by the NewerNoncurrentVersions parameter, and have been noncurrent for more than NoncurrentDays.

For example, if an object has only two noncurrent versions and the configured rule has a NewerNoncurrentVersions of 2, those two versions won't be deleted. However, if there are three noncurrent versions, the older version will be deleted if it has been noncurrent for more than NoncurrentDays.

The NoncurrentDays for a version (i.e. the number of days a version has been noncurrent) is calculated from when its next version is created, and the amount of days a version has been noncurrent is rounded down to the largest integer less than or equal to the actual passed days.

The Expiration rule

The Expiration rule is used to delete objects after a certain time. When an object reaches the end of its lifetime, the system takes an expiration action based on which versioning state the bucket is in:

  • nonversioned buckets - the object will be permanently removed
  • versioning-enabled bucket - if the current object is not a delete marker, the system adds a delete marker on top of it; this makes the current version noncurrent, and the delete marker the current version
  • versioning-suspended bucket - the system creates a delete marker with a null version id on top of the versions stack of the object, effectively deleting the object

Expiration date When using an Expiration with a Date you need to provide a date set to the midnight UTC. Since filters are not currently supported, an expiration date means that every object in the bucket needs to be expired at after a certain date.

Expiration days Setting the Expiration with a Days parameter, all the objects in the buckets will expire after a certain amount of days since their creation.

The expired objects delete markers When an object has a single delete marker to represent it (maybe because some NoncurrentVersionExpiration deleted all the noncurrent versions), it is called an expired object delete marker. When a versioned bucket has some expiration rules applied to it, all the expired object delete markers get automatically deleted too.

The ExpiredObjectDeleteMarker field It is also possible to only delete expired object delete markers automatically without setting an expiration rule, defining a new rule with just an ExpiredObjectDeleteMarker in it, e.g.:

"Expiration": {
"ExpiredObjectDeleteMarker": true
}

Expiration rules containing both Date/Days and ExpiredObjectDeleteMarker are not allowed.

Checking the expiration When you set an expiration rule on a bucket, performing an HeadObject or GetObject on a target object, you will get an Expiration header in this format: Expiration: expiry-date="Tue, 19 Nov 2024 00:00:00 GMT", rule-id="<id of the lifecycle rule>"


Example: how to apply a lifecycle configuration

Create a file containing these example lifecycle configuration, named lifecycle.json:

{
"Rules": [
{
"ID": "NoncurrentVersionExpiration Rule 1",
"Status": "Enabled",
"NoncurrentVersionExpiration": {
"NewerNoncurrentVersions": 3,
"NoncurrentDays": 2
}
},
{
"ID": "Expiration Rule 1",
"Status": "Enabled",
"Expiration": {
"Days": 10
}
}
]
}

In the same folder, invoke the following command to set the lifecycle configuration for the bucket:

aws s3api --endpoint https://s3.cubbit.eu put-bucket-lifecycle-configuration --lifecycle-configuration file://lifecycle.json --bucket my-cubbit-bucket

If the command succeeds, the lifecycle configuration has been successfully applied. To verify it, you can invoke the following command:

aws s3api --endpoint https://s3.cubbit.eu get-bucket-lifecycle-configuration --bucket my-cubbit-bucket
note

Please verify that you have replaced "my-cubbit-bucket" with an existing bucket.

The ID is optional and a random one will be set if not provided.

Unsupported features

Currently, only one rule per bucket is supported. Here's a list of unsupported instructions:

  • AbortIncompleteMultipartUpload
  • Filter
  • NoncurrentVersionTransition
  • Prefix
  • Transition

Bucket Lifecycle Policies UI

The Bucket Lifecycle Policies UI provides an easy and intuitive way to manage the lifecycle of objects stored in your buckets. With this interface, you can define automated rules to transition or delete objects based on predefined conditions, helping you optimize storage costs and maintain data compliance.

Key Features

  • Simple Rule Creation: Easily set up rules to move or delete objects based on their age or other conditions.
  • Clear Policy Overview: View all existing lifecycle policies in one place, with details on their actions and conditions.
  • Flexible Configuration: Customize policies to fit your storage needs, whether it's archiving old data or removing expired files.
  • Status Indicators: Quickly see which policies are active and applied to your bucket.
  • Lifecycle Rule Configuration: Define and view details of a specific rule, including the rule name and scope.
  • Review Transition and Expiration Actions: A structured breakdown of how objects transition over time.
    • Current Version Actions: Displays what happens to newly uploaded objects. For example, an object may expire after a set period (e.g., 30 days).
    • Noncurrent Version Actions: Shows how previous versions of objects are managed, such as deletion after a retention period (e.g., 1 day).
  • Policy List: A table displaying all existing lifecycle policies, including their names, actions, and status.
  • Create/Edit Policy Button: A guided process to define new lifecycle policies or modify existing ones.
  • Enable/Disable Toggle: Easily activate or deactivate policies as needed.

The interface is designed to be user-friendly, allowing both beginners and experienced users to efficiently manage their bucket lifecycles with minimal effort. Explore the UI and take control of your storage management today!

Lifecycle rule preview visualized by the DS3 Console