Bucket object lifecycle configuration

Object Storage lets you manage lifecycles for objects in buckets. To upload the lifecycle configuration to Object Storage, you need to create an XML document as described in this section. You can obtain a document in this format by downloading an existing configuration.

General configuration format:

<LifecycleConfiguration>
    <Rule>
        <ID>Rule description</ID>
        <Status>{Enabled|Disabled}</Status>
        <Filter>
           <Prefix>key_ prefix</Prefix>
        </Filter>

        <Transition>
            <StorageClass>Storage class ID</StorageClass>
            <!-- <Date> or <Days> -->
        </Transition>
        ...
        <Expiration>
            <!-- <Date> or <Days> -->
        </Expiration>
        ...
    </Rule>
    <Rule>
      ...
    </Rule>
    ...
</LifecycleConfiguration>

A configuration may contain up to 1000 rules.

Elements

Element Description
Date Date of rule execution.

Format: ISO 8601, for example, YYYY-MM-DD. Time is always 00:00 UTC.

Path: LifecycleConfiguration\Rule\Expiration\Date.
Days Rule execution interval.

This is defined by the number of days since the object was uploaded.

Path: LifecycleConfiguration\Rule\Expiration\Days.
Expiration Rule for deleting an object from Object Storage.

Contains the Days or Date element, which sets when the action expires.

Path: LifecycleConfiguration\Rule\Expiration.
Filter Object filter.

Contains no more than one Prefix element. If an empty <Filter></Filter> filter is set, the rule applies to all objects in a bucket.

Path: LifecycleConfiguration\Rule\Filter.
ID Unique rule ID.

Custom text up to 255 characters long, such as "Delete in 20 days". An optional parameter that you can use to search for a rule in a configuration.

If no ID is specified, Object Storage generates one automatically.

Path: LifecycleConfiguration\Rule\ID.
LifecycleConfiguration Root element of an XML document.

It may contain up to 1000 Rule elements.

Path: LifecycleConfiguration.
Prefix Key prefix.

You can use it to filter objects that meet the rule.

Examples of prefixes for the key some/long/object/key: some, some/, some/lo.

Filters can only contain one prefix.

Path: LifecycleConfiguration\Rule\Filter\Prefix.
Rule Rule description.

Objects that meet the rule are set by the Filter element. Actions on objects are defined by the Transition and Expiration elements. There can be multiple actions of each type.

Path: LifecycleConfiguration\Rule.
Status Rule status.

You can activate a rule by setting <Status>Enabled</Status> for it, or disable it by setting <Status>Disabled</Status>.

Path: LifecycleConfiguration\Rule\Status.
StorageClass Storage class of an object.

Path: LifecycleConfiguration\Rule\Transition\StorageClass.
Transition The rule to change the storage class of an object.

It contains the StorageClass element, which defines the target storage class and the Date or Days element, which sets when the action expires.

You can only move objects from standard to cold storage.

Path: LifecycleConfiguration\Rule\Transition\.

Example

The rule below applies to all objects uploaded to the bucket as follows:

  • They are moved to cold storage 30 days after being uploaded to Object Storage.
  • They are deleted from Object Storage 365 days after being uploaded.
<LifecycleConfiguration>
    <Rule>
        <ID>Move and then delete</ID>
        <Status>Enabled</Status>
        <Filter>
           <Prefix></Prefix>
        </Filter>
        <Transition>
            <StorageClass>COLD</StorageClass>
            <Days>30</Days>
        </Transition>
        <Expiration>
            <Days>365</Days>
        </Expiration>
    </Rule>
</LifecycleConfiguration>