Skip to content

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.

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.

Each <Rule> element contains the following child elements:

The <Filter> element supports the following child elements:

An empty <Filter/> applies the rule to all objects in the bucket.

The <Expiration> element supports the following child elements:

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.

<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>