It is possible to configure a lifecycle of a group of objects so that their storage costs can effectively be managed. A lifecycle configuration is a set of rules that defines actions applied to a group of objects stored on Object Storage.
Currently the expiration action is supported on the platform. It defines when objects expire, to delete objects automatically on your behalf.
There might be for example a need to store log files for a week or a month, after which they become obsolete. It is possible to set a lifecyle rule to delete them automatically when they become obsolete.
Currently Lifecyle Management on Object Storage available on every AWS S3 compliant tool (skd, aws-cli, boto, etc), but currently not yet available on the Scaleway management console.
A lifecycle configuration is an XML file, containing a set of rules with predefined actions that you want Object Storage to perform on objects during their lifetime:
<LifecycleConfiguration> <Rule> ... </Rule> <Rule> ... </Rule> ... </LifecycleConfiguration>
Rule consists of the following:
Filteridentifying a subset of objects to which the rule applies.
Statuswhether the rule is in effect (A rule can be present but
Rule: Child of
Container for a lifecycle rule. There is a limit of thousand (1000) rules per bucket.
Filter: Child of
Container for elements that describe that identifies the subset of object the rule applies for. If the content of the tag is empty, the rule applies to all objects in the bucket.
And: Child of
Container for chaining rule filters. For example:
<And> <Prefix>myprefix</Prefix> <Tag> <Key>mytagkey1</Key> <Value>mytagvalue1</Value> </Tag> </And>
Which applies the
Prefix rule and the
Prefix: Child of
Object key prefix identifying one or more objects to which the rule applies. Object Storage does limit this token to 1 per
Tag: Child of
Container for specifying a
Key and a
Status: Child of
Describes whether or not a rule is to be enabled. Values:
Transition: Child of
Specifies a period and a destination for an object lifetime
Days: Child of
Transition and / or
Specifies the number of days after object creation when the rule takes effect.
StorageClass: Child of
Specifies the Storage Class to which the object shall be transfered to.
Expiration: Child of
Describe a period in the objet’s lifetime for a deletion. If versioning is enabled, this rule shall only delete the current version of an object.
ID: Child of
Unique identifier for the rule. This value is limited to 255 characters.
The lifecycle configuration above translates to the following effective rules:
On this rule named “id-1”, we set the objects with the ‘myprefix’ Prefix and the tags ‘mytagkey1’, ‘mytagkey2’ sets to ‘mytagvalue1’ and ‘mytagvalue2’ to expire after one day.
PUT /?lifecycle HTTP/1.1 Host: bucketname.s3.nl-ams.scw.cloud Content-MD5: e0d656aa8bed46fe766420c6d21537d5 Authorization: authorization string <LifecycleConfiguration> <Rule> <ID>ExampleRule</ID> <Filter> <Prefix>documents/</Prefix> </Filter> <Status>Enabled</Status> <Expiration> <Days>30</Days> </Expiration> </Rule> </LifecycleConfiguration>
HTTP/1.1 200 OK
GET /?lifecycle HTTP/1.1 Host: bucketname.s3.nl-ams.scw.cloud Authorization: authorization string
HTTP/1.1 200 OK x-amz-id-2: txda274593e2dc4974a82cc-005cdbe130 x-amz-request-id: txda274593e2dc4974a82cc-005cdbe130 Date: Wed, 15 May 2019 09:51:44 GMT Content-Length: 238 <?xml version="1.0" encoding="UTF-8"?> <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Rule> <ID>ExampleRule</ID> <Filter> <Prefix>documents/</Prefix> </Filter> <Status>Enabled</Status> <Expiration> <Days>30</Days> </Expiration> </Rule> </LifecycleConfiguration>
DELETE /?lifecycle HTTP/1.1 Host: bucketname.s3.nl-ams.scw.cloud Authorization: authorization string
204 No Content Content-Length: 0 Date: Wed, 15 May 2019 09:59:29 GMT