Bucket object lifecycle configuration
Object Storage allows you to manage 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>
<ObjectSizeGreaterThan>minimum object size</ObjectSizeGreaterThan>
<ObjectSizeLessThan>maximum object size</ObjectSizeLessThan>
<Prefix>key prefix</Prefix>
</Filter>
<Expiration>
<!-- <Date> or <Days> -->
<!-- <ExpiredObjectDeleteMarker> -->
</Expiration>
<NoncurrentVersionExpiration>
<NoncurrentDays>Deleting versions 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 1000 rules.
Elements
Element | Description |
---|---|
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 . |
Date |
Rule execution date. Format: ISO 8601 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. Minimum value: 1. Path: LifecycleConfiguration\Rule\Expiration\Days . |
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 aren't any non-current versions.Path: LifecycleConfiguration\Rule\Expiration . |
Filter |
Object filter. Contains no more than one element of each type: Prefix , ObjectSizeGreaterThan , or ObjectSizeLessThan .If an empty <Filter></Filter> is set, the rule applies to all bucket objects.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 . |
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. Sample prefixes for the key some/long/object/key : some , some/ , and some/lo .A filter may 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 Expiration element. There can be multiple actions of each type.Path: LifecycleConfiguration\Rule . |
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 . |
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 . |
Example
The rule below applies to all objects uploaded to the bucket as follows:
- 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>
<Expiration>
<Days>365</Days>
</Expiration>
<AbortIncompleteMultipartUpload>
<DaysAfterInitiation>5</DaysAfterInitiation>
</AbortIncompleteMultipartUpload>
</Rule>
</LifecycleConfiguration>