Life cycle configuration in Object Storage
Last updated on
Life cycle configurations let you to automatically expire or delete objects in a bucket based on age, prefix, or tag filters. Each life cycle configuration is scoped to a single bucket and can contain up to 1000 rules.
Configuration format
Section titled “Configuration format”Life cycle configurations use standard S3 XML format. Set the configuration on a bucket using the AWS CLI put-bucket-lifecycle-configuration command or the S3-compatible API.
Supported elements
Section titled “Supported elements”Each <Rule> element contains the following child elements:
| Element | Required | Description |
|---|---|---|
<ID> | Yes | Unique identifier for the rule within the configuration. Maximum 255 characters. |
<Filter> | Yes | Specifies which objects the rule applies to. Use an empty <Filter/> to apply the rule to all objects. |
<Status> | Yes | Enabled or Disabled. Disabled rules are inactive and no actions are performed. |
<Expiration> | No | Defines when the current version of an object expires. |
<NonCurrentVersionExpiration> | No | Defines when non-current versions of an object expire (versioned buckets only). |
Filter
Section titled “Filter”The <Filter> element supports the following child elements:
| Element | Description |
|---|---|
<Prefix> | Matches objects with the specified key prefix. |
<Tag> | Matches objects with the specified key/value tag. Contains <Key> and <Value> sub-elements. |
<And> | Combines multiple filter conditions. Required when using both <Prefix> and <Tag> together. |
An empty <Filter/> applies the rule to all objects in the bucket.
Expiration
Section titled “Expiration”The <Expiration> element supports the following child elements:
| Element | Description |
|---|---|
<Days> | Expires objects the specified number of days after their upload date. |
<Date> | Expires objects on or after the specified date (ISO 8601 format). |
NonCurrentVersionExpiration
Section titled “NonCurrentVersionExpiration”The <NonCurrentVersionExpiration> element applies to non-current object versions in versioned buckets. When versioning is enabled and an object is deleted, the deleted object becomes a non-current version with a delete marker inserted as the current version. This element permanently removes those non-current versions.
| Element | Description |
|---|---|
<NoncurrentDays> | Removes non-current versions the specified number of days after they become non-current. |
Constraints
Section titled “Constraints”| Constraint | Value |
|---|---|
| Maximum rules per configuration | 1000 |
| Deletion delay after expiration | Approximately 10 days |
| Supported filter combinations | Prefix only, Tag only, Prefix + Tag (using <And>) |
Example configuration
Section titled “Example configuration”<LifecycleConfiguration> <Rule> <ID>expire-old-backups</ID> <Filter> <Prefix>backups/</Prefix> </Filter> <Status>Enabled</Status> <Expiration> <Days>90</Days> </Expiration> </Rule> <Rule> <ID>expire-tagged-temp-objects</ID> <Filter> <And> <Prefix>tmp/</Prefix> <Tag> <Key>env</Key> <Value>staging</Value> </Tag> </And> </Filter> <Status>Enabled</Status> <Expiration> <Days>30</Days> </Expiration> </Rule></LifecycleConfiguration>