Bucket object lifecycle configuration
Written by
Updated at August 2, 2024
Object Storage allows managing object lifecycles in a bucket. To upload 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>
<And>
<ObjectSizeGreaterThan>minimum object size</ObjectSizeGreaterThan>
<ObjectSizeLessThan>maximum object size</ObjectSizeLessThan>
<Prefix>key prefix</Prefix>
<Tag>
<Key>tag key</Key>
<Value>tag value</Value>
</Tag>
...
</And>
<ObjectSizeGreaterThan>minimum object size</ObjectSizeGreaterThan>
<ObjectSizeLessThan>maximum object size</ObjectSizeLessThan>
<Prefix>key prefix</Prefix>
<Tag>
<Key>tag key</Key>
<Value>tag value</Value>
</Tag>
</Filter>
<Transition>
<StorageClass>Storage class ID</StorageClass>
<!-- <Date> or <Days> -->
</Transition>
<Expiration>
<!-- <Date> or <Days> -->
<!-- <ExpiredObjectDeleteMarker> -->
</Expiration>
<NoncurrentVersionTransition>
<StorageClass>Storage class ID</StorageClass>
<NoncurrentDays>Migrating versions that are older than the specified number of days</NoncurrentDays>
</NoncurrentVersionTransition>
<NoncurrentVersionExpiration>
<NoncurrentDays>Deleting versions that are older than the specified number of days</NoncurrentDays>
</NoncurrentVersionExpiration>
<AbortIncompleteMultipartUpload>
<DaysAfterInitiation>Deleting uploads not completed within the specified number of days</DaysAfterInitiation>
</AbortIncompleteMultipartUpload>
...
</Rule>
<Rule>
...
</Rule>
...
</LifecycleConfiguration>
A configuration may contain up to 1,000 rules.
Elements
Element | Description |
---|---|
LifecycleConfiguration |
Root element of an XML document. It may contain up to 1,000 Rule elements.Path: LifecycleConfiguration . |
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 . |
ID |
Unique rule ID. Any text up to 255 characters long, e.g., "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 . |
Status |
Rule status. You can activate a rule by setting <Status>Enabled</Status> or deactivate it by setting <Status>Disabled</Status> .Path: LifecycleConfiguration\Rule\Status . |
Filter |
Object filter. Contains no more than one element of each type: And , Prefix , ObjectSizeGreaterThan , ObjectSizeLessThan , or Tag .If an empty <Filter></Filter> is set, the rule applies to all bucket objects.Path: LifecycleConfiguration\Rule\Filter . |
ObjectSizeGreaterThan |
Minimum object size in bytes. The rule applies to objects whose size is greater than or equal to the set one. A filter may only contain one minimum object size. Path: LifecycleConfiguration\Rule\Filter\ObjectSizeGreaterThan . |
ObjectSizeLessThan |
Maximum object size in bytes. The rule applies to objects whose size is less than or equal to the set one. A filter may only contain one maximum object size. Path: LifecycleConfiguration\Rule\Filter\ObjectSizeLessThan . |
Prefix |
Key prefix. The rule applies to objects with the specified key prefix. Examples of prefixes for the some/long/object/key key: some , some/ , and some/lo .A filter may only contain one prefix. Path: LifecycleConfiguration\Rule\Filter\Prefix . |
Tag |
Object tag The rule applies to objects to which the specified tag is assigned. The filter may contain only one object tag. Path: LifecycleConfiguration\Rule\Filter\Tag . |
And |
AND logical operator for filters.May contain any combination of the following elements: Prefix , ObjectSizeGreaterThan , ObjectSizeLessThan , Tag .Path: LifecycleConfiguration\Rule\Filter\And . |
Key |
Object tag key Path: LifecycleConfiguration\Rule\Filter\Tag\Key . |
Value |
Object tag value Path: LifecycleConfiguration\Rule\Filter\Tag\Value . |
Transition |
Rule for changing the storage class of an object. It contains the StorageClass element that defines the target storage class and the Date or Days element that determines when the action expires.You can move objects from STANDARD to COLD or ICE storage and from COLD to ICE storage.Path: LifecycleConfiguration\Rule\Transition\ . |
StorageClass |
Storage class of the object. Path: LifecycleConfiguration\Rule\Transition\StorageClass . |
Expiration |
Rule for deleting an object from Object Storage. Contains the Days or Date element that sets the action expiry.It may also contain ExpiredObjectDeleteMarker : An expired object delete marker that indicates whether Object Storage will remove the delete marker if there are no non-current versions.Path: LifecycleConfiguration\Rule\Expiration . |
Date |
Rule execution date. Format: ISO 8601 YYYY-MM-DD . Time: 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. Minimum value: 1. Path: LifecycleConfiguration\Rule\Expiration\Days . |
NoncurrentVersionTransition |
Rule for changing the storage class of non-current object versions. This rule only applies to non-current versions of an object rather than to the entire object. It contains the StorageClass element that defines the target storage class and the NoncurrentDays element that sets the action expiry.You can move objects from STANDARD to COLD or ICE storage and from COLD to ICE storage.Path: LifecycleConfiguration\Rule\NoncurrentVersionTransition . |
NoncurrentVersionExpiration |
Rule for deleting non-current object versions from Object Storage. This rule only applies to non-current versions of an object rather than the entire object. Contains the NoncurrentDays element that sets the action expiry.Path: LifecycleConfiguration\Rule\NoncurrentVersionExpiration . |
AbortIncompleteMultipartUpload |
Rule for deleting uploads not completed within the specified number of days. Contains the DaysAfterInitiation element that sets when the rule applies.Path: LifecycleConfiguration\Rule\AbortIncompleteMultipartUpload\ DaysAfterInitiation . |
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.
- Deleting incomplete uploads from Object Storage five days after the start of the object upload.
<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>
<AbortIncompleteMultipartUpload>
<DaysAfterInitiation>5</DaysAfterInitiation>
</AbortIncompleteMultipartUpload>
</Rule>
</LifecycleConfiguration>