Create a bucket lifecycle configuration
A PUT operation uses the lifecycle query parameter to set lifecycle
settings for the bucket. An integrity check is required by using either
content-md5, a x-amz-checksum- header, or the x-amz-content-sha256 header.
Syntax
PUT https://{endpoint}/{bucket-name}?lifecycle # path style
PUT https://{bucket-name}.{endpoint}?lifecycle # virtual host style
Payload elements
| Name | Type | Description | Children | Ancestor | Constraint |
|---|---|---|---|---|---|
| LifecycleConfiguration | Container | Root level tag for the LifecycleConfiguration parameters | Rule | None | Limit 1 |
| Rule | Container | A lifecycle rule for individual objects in an S3 bucket. | ID, Status, Filter, Expiration, NoncurrentVersionExpiration, AbortIncompleteMultipartUpload | LifecycleConfiguration | Limit 1 Must contain a Filter element. |
| ID | String | Unique identifier for the rule. The value cannot be longer than 255 characters. | None | Rule | Must consist of (a-z, A- Z, 0-9) and the following symbols: !`_ .*'()- |
| Filter | String | The Filter is used to identify objects that a Lifecycle Rule applies to. A Filter must have exactly one of Prefix specified. | Prefix | Rule | Required on a Rule element. |
| Expiration | Container | Specifies the expiration for the lifecycle of the object in the form of date, days. If Days or Date is specified and Object Versioning is Enabled or Suspended on the bucket, the rule will create a delete marker on the object (if one is not already present as the current version). If versioning is suspended, expiration will create a null version, possibly overwriting an existing null version. If the only version left on the object is a delete marker (i.e. ExpiredObjectDeleteMarker), the delete marker is subject to expiration and it will be permanently deleted. |
Days, Date, ExpiredObjectDeleteMarker | Rule | Limit 1 |
| Days | Non-negative integer | Specifies days since the object has been last modified after which the object is eligible for expiration. | None | Expiration | Must be a value greater than 0. |
| Date | Date string in ISO-8601 | Specifies date after which the objects are eligible for expiration. | None | Expiration | Must be in ISO 8601 Format and the date must be in the future. |
| ExpiredObjectDeleteMarker | Boolean | In a versioning enabled bucket, a delete marker with zero non-current versions is referred to
as the expired object delete marker. Action is used to remove the expired object delete
markers. This element should be used when you want to remove EODMs only and not expire current versions of an object via delete marker creation. |
None | Expiration | Must be true or false. |
| NoncurrentVersionExpiration | Container | Specifies the expiration of non-current/retained versions of an object in days. | NoncurrentDays | Rule | Limit 1 |
| NoncurrentDays | Positive Integer | Specifies how long (from the time the objects became non-current), to retain non-current object versions before permanently removing them. Deleted version cannot be recovered. | None | NoncurrentVersionExpiration | Must be a value greater than 0. |
| AbortIncompleteMultipartUpload | Container | Specifies the expiration of incomplete multi-part uploads. | DaysAfterInitiation | Rule | Limit 1 |
| DaysAfterInitiation | Non-negative Integer | Specifies how long in days to allow multi-part uploads to remain in progress before being automatically aborted. If applicable, a multi-part upload is aborted if it is older (as determined by upload initiation date) than the configured days. | None | AbortIncompleteMultipartUpload | Must be a value greater than 0. |
| Filter | Container | The Filter is used to identify objects that a Lifecycle Rule applies to. A Filter must have exactly one child. | Prefix, And, ObjectSizeGreaterThan, ObjectSizeLessThan, Tag | Rule | Required |
| ObjectSizeGreaterThan | Non-negative Integer | Restrict lifecycle action to objects greater than a specific size. | None | Filter, And | Must be a value greater than 0. |
| ObjectSizeLessThan | Non-negative Integer | Restrict lifecycle action to objects less than a specific size. | None | Filter, And | Must be a value greater than 0. |
| Prefix | String | Restrict lifecycle action to objects with names that contain this prefix. | None | Filter, And | String must be less than 1024 characters. |
| And | Container | Restrict lifecycle action to two or more filter conditions. | Prefix,ObjectSizeGreaterThan, ObjectSizeLessThan, Tag | Filter, | May contain one or more Tag elements. |
| Tag | Container | Restrict lifecycle action to objects with specific tag. | Key, Value | Filter, And | Must define both a Key and Filter. |
| Key | String | Restrict lifecycle action to objects with specific key. | None | Tag | String must be less than 128 characters. |
| Value | String | Restrict lifecycle action to objects with specific value. If empty, all tag values are matched. | None | Tag | String must be less than 256 characters. |
An integrity check is required by using either content-md5, a x-amz-checksum- header, or the x-amz-content-sha256 header. For example, the Content-MD5 header needs to be the binary representation of a base64-encoded MD5 hash. The following snippet shows one way to achieve the content for that particular header.
echo -n (XML block) | openssl dgst -md5 -binary | openssl enc -base64
Sample request
PUT /cit-test?lifecycle HTTP/1.1
Host: 192.168.35.22
User-Agent: curl/7.64.1
Accept: */*
Date: Fri, 28 Feb 2020 14:12:06 +0000
Authorization: AWS MOfXYiHQ9QTyD2ALoiOh:WrlFRE2KMmhutBf3CxIZoNLl/ko=
Content-MD5: To3JYtaVNR3+aGYtl1dlmw==
Content-Length: 321
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Rule>
<ID>ID1</ID>
<Status>Enabled</Status>
<Filter/>
<Expiration>
<Days>100</Days>
</Expiration>
</Rule>
</LifecycleConfiguration>
Sample response
We are completely uploaded and fine
HTTP/1.1 200 OK
Date: Fri, 28 Feb 2020 14:12:06 GMT
X-Clv-Request-Id: 587d909f-4939-41ef-8c16-80aea16a0587
Server: Cleversafe/3.14.9.53
X-Clv-S3-Version: 2.5
x-amz-request-id: 587d909f-4939-41ef-8c16-80aea16a0587
Content-Length: 0