Skip to main content

Lifecycle Configuration


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.


Create a file containing the following lifecycle configuration, named lifecycle.json:

"Rules": [
"Status": "Enabled",
"NoncurrentVersionExpiration": {
"NewerNoncurrentVersions": 3,
"NoncurrentDays": 2

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

aws s3api --endpoint 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 get-bucket-lifecycle-configuration --bucket my-cubbit-bucket

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

Unsupported features

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

  • AbortIncompleteMultipartUpload
  • Expiration
  • Filter - even if specified, it will be ignored
  • ID
  • NoncurrentVersionTransition
  • Prefix
  • Transition