Lifecycle
All available methods for working with object lifecycle:
- GetBucketLifecycleConfiguration — view the lifecycle configuration.
- PutBucketLifecycle — set a configuration with lifecycle rules.
- DeleteBucketLifecycle — delete the lifecycle configuration.
The configuration with lifecycle rules is transmitted in XML format. To filter objects that fall under a rule, tags and the object key are used.
The GET operation returns information about the lifecycle configuration set for the bucket.
In the bucket's lifecycle configuration, you can specify a lifecycle rule using the object key name prefix, one or more object tags, or a combination of both parameters. The response contains a filter element that can be used to change the filter parameters and select the subset of objects to which the rule should apply.
Example request:
GET /?lifecycle HTTP/1.1Host: my-test-bucket1.hb.bizmrg.comx-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-date: 20200831T001757ZAuthorization: AWS4-HMAC-SHA256 Credential=II5JDQBAN3JYM4DNEB6C/20200831/ru-msk/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=e92e48fb16dad3d9d332460adde86493b8930262d9385e002b0408e17a2781f4
Example response:
HTTP/1.1 200 OKDate: Mon, 31 Aug 2020 17:44:35 GMTx-amz-request-id: tx000000000000000023935-005a613936-fcf92-ru-mskaContent-Type: application/xmlContent-Length: 488Connection: close<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>Expire old logs</ID><Prefix>logs/</Prefix><Status>Enabled</Status><Expiration><Days>90</Days></Expiration></Rule></LifecycleConfiguration>
In the bucket's lifecycle configuration, you can specify a lifecycle rule using the object key name prefix.
The PUT operation creates a new lifecycle configuration for the bucket or replaces an existing one.
Example request:
PUT /?lifecycle HTTP/1.1Host: my-test-bucket1.hb.bizmrg.comContent-Length: 488Content-Type: application/xmlx-amz-content-sha256: 34850007f92ec3331486b48fd7db15f48315fe73c4a9b135e6d9fd629276c1e7x-amz-date: 20200831T000345ZAuthorization: AWS4-HMAC-SHA256 Credential=II5JDQBAN3JYM4DNEB6C/20200831/ru-msk/s3/aws4_request,SignedHeaders=content-md5;content-type;host;x-amz-content-sha256;x-amz-date,Signature=fc07a541c2acdbf7527eba358afa0a6d460c9bfec539dd29dfa6b5b854aae109<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>Expire old logs</ID><Prefix>logs/</Prefix><Status>Enabled</Status><Expiration><Days>90</Days></Expiration></Rule></LifecycleConfiguration>
Example response:
HTTP/1.1 200 OKDate: Mon, 31 Aug 2020 17:31:43 GMTx-amz-request-id: tx00000000000000010ad2b-005a6135e2-f647d-ru-mskaContent-Length: 0Content-Type: application/xmlConnection: close
The DELETE operation deletes the lifecycle configuration from the specified bucket. All lifecycle configuration rules are deleted from the lifecycle subresource associated with the bucket, which makes it possible to exclude the expiration from objects. As a result, the service will no longer automatically delete objects according to the rules contained in the deleted lifecycle configuration.
Example request:
DELETE /?lifecycle HTTP/1.1Host: my-test-bucket1.hb.ru-msk.vkcloud-storage.rux-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-date: 20200831T204101ZAuthorization: AWS4-HMAC-SHA256 Credential=II5JDQBAN3JYM4DNEB6C/20200831/ru-msk/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=376fe41764fe6493a33160b36055d8f617b92f9337bce0cf91bc9c5b1e7482b2
Example response:
HTTP/1.1 204 No ContentDate: Mon, 31 Aug 2020 18:13:21 GMTConnection: close