Skip to main content

PutBucketLifecycle

PutBucketLifecycle is the older, deprecated way to replace a bucket's lifecycle rules - the rules that tidy a bucket up by expiring old versions and abandoned uploads (Lifecycle policies explains them). STRG answers a request in its format with 501 NotImplemented, so a client knows straight away, and the bucket's existing rules stay exactly as they were. PutBucketLifecycleConfiguration is the way to set lifecycle rules: it sends the same request, with each rule's prefix inside Filter.

Deprecated

Amazon S3 deprecated PutBucketLifecycle in favour of PutBucketLifecycleConfiguration. The AWS SDK for JavaScript v3 does not offer this operation at all; the AWS CLI (put-bucket-lifecycle) and boto3 (put_bucket_lifecycle) still do.

Good to know on STRG
  • This operation's format puts a top-level Prefix on every rule, and STRG answers such a rule with 501 NotImplemented. Nothing about the bucket changes.
  • A document whose rules carry Filter rather than Prefix is the PutBucketLifecycleConfiguration format, and STRG handles it exactly as that operation does.
  • x-amz-expected-bucket-owner is welcome and has nothing to check: a key only ever reaches buckets of its own account.

When you'd use it​

  • An older script or backup tool that still calls put-bucket-lifecycle gets a clear 501 NotImplemented and leaves the bucket's rules untouched, so nothing changes without anyone noticing.
  • Moving such a script over takes two small changes - the command, and the prefix moving into Filter - and the examples below show both side by side.
  • A tool that sends the newer Filter format under this name keeps working: STRG reads the document as PutBucketLifecycleConfiguration and stores the rules.

Request​

PUT /?lifecycle HTTP/1.1
Host: my-bucket.s3.eu-central-1.strg.com
Authorization: AWS4-HMAC-SHA256 Credential=...
x-amz-date: 20260926T120000Z
x-amz-content-sha256: <SHA-256 of the body>
Content-MD5: <base64 MD5 of the body>
Content-Type: application/xml

<LifecycleConfiguration>...</LifecycleConfiguration>

Path-style, the same request is PUT /my-bucket?lifecycle on s3.eu-central-1.strg.com; Addressing has the details.

Permissions​

The access key needs Manage lifecycle rules (bucket-lifecycle:write). A key limited to certain buckets reaches only those. A key prefix does not narrow this operation, since the configuration belongs to the whole bucket. A key without the permission gets 403 AccessDenied before the body is read. Access keys has the full picture.

URI parameters​

NameTypeRequiredDescription
BucketStringYesThe bucket whose lifecycle rules would be replaced.
lifecycleFlagYesSelects the lifecycle subresource. Takes no value.

Any other query parameter gets 501 NotImplemented, so a client knows straight away, except the X-Amz-* parameters of a presigned URL and the x-id parameter the JavaScript SDK adds.

Request headers​

NameTypeRequiredDescription
Content-MD5StringConditionalBase64 MD5 of the body. One integrity header is required: this or an x-amz-checksum-* header, and a request with neither gets 400 InvalidRequest. A value that does not match the body is 400 BadDigest. The AWS CLI and SDKs send a checksum automatically.
x-amz-sdk-checksum-algorithmStringNoThe algorithm of the x-amz-checksum-* header the SDK sends. Accepted.
x-amz-expected-bucket-ownerStringNoWelcome, with nothing to check: an access key only ever reaches its own account's buckets.

Request body​

A LifecycleConfiguration document of at most 2 MiB. This operation's rule format always carries a top-level Prefix, which STRG answers first, so the rest of the rule is never read:

ElementTypeRequiredDescription
RuleContainerYesOne lifecycle rule. Repeated.
Rule/PrefixStringYesAnswered with 501 NotImplemented on any rule that carries it. The same prefix in Filter/Prefix, sent as PutBucketLifecycleConfiguration, sets the rule.
Rule/IDStringNoNever read: the rule's Prefix has already been answered.
Rule/StatusStringYesNever read: the rule's Prefix has already been answered.
Rule/ExpirationContainerNoNever read: the rule's Prefix has already been answered.
Rule/NoncurrentVersionExpirationContainerNoNever read: the rule's Prefix has already been answered.
Rule/AbortIncompleteMultipartUploadContainerNoNever read: the rule's Prefix has already been answered.
Rule/TransitionContainerNoNever read: the rule's Prefix has already been answered. Every object stays in one storage class, so neither operation has transitions.
Rule/NoncurrentVersionTransitionContainerNoNever read: the rule's Prefix has already been answered. Neither operation has transitions, for the same reason.

The actions STRG stores and their limits are on PutBucketLifecycleConfiguration and Lifecycle policies.

Response​

A request in this operation's format always gets an error document, so there is no success response to describe. The x-amz-request-id header carries the request ID, handy for a support request.

Errors​

The answers this operation can give, and the situation behind each. Once the key is accepted in this endpoint's region, the request is answered before the bucket is looked up, so a bucket that does not exist gets the same answer as one that does.

CodeHTTP statusWhen
NotImplemented501A rule carries a top-level Prefix - every request in this operation's format - or the request carries a query parameter this operation does not take.
MalformedXML400The body is not well-formed XML, not UTF-8, its root element is not LifecycleConfiguration, or it uses a comment, CDATA section, DOCTYPE, processing instruction or namespace prefix.
InvalidRequest400The request carries neither Content-MD5 nor an x-amz-checksum-* header.
BadDigest400Content-MD5 does not match the body.
XAmzContentSHA256Mismatch400x-amz-content-sha256 does not match the body.
MaxMessageLengthExceeded400The body is larger than 2 MiB.
AccessDenied403The access key does not hold Manage lifecycle rules, or the bucket is outside its scope.
InvalidAccessKeyId403The access key does not exist, has expired or been revoked - or it was created moments ago and is not yet usable in this endpoint's region, where the account already stores data, in which case the same request works shortly after.
NoSuchBucket404The account has no storage in this endpoint's region yet. The bucket is not looked for, whatever the body holds.
SignatureDoesNotMatch403The request signature does not match.
RequestTimeTooSkewed403The request time is more than 15 minutes from the server's.
AuthorizationHeaderMalformed400The signature's credential scope names a region other than the endpoint's.
ServiceUnavailable503A temporary failure. The AWS SDKs retry it on their own.

Differences from Amazon S3​

AspectAmazon S3STRG
The operationDeprecated, still accepted501 NotImplemented, with the bucket's rules unchanged. PutBucketLifecycleConfiguration sets the same rules.
x-amz-expected-bucket-ownerChecked against the bucket ownerWelcome, with nothing to check: a key only reaches its own account's buckets

Differences from Amazon S3 covers the ones that apply to every operation.

Examples​

Moving from this operation to PutBucketLifecycleConfiguration takes two changes: the command, and the prefix moving into Filter. Here is a rule that removes objects under logs/ 30 days after upload, previous versions 7 days after they are replaced, and incomplete multipart uploads after 2 days:

Instead of put-bucket-lifecycle with "Prefix": "logs/" on the rule:

aws s3api put-bucket-lifecycle-configuration \
--bucket my-bucket \
--endpoint-url https://s3.eu-central-1.strg.com \
--region eu-central-1 \
--lifecycle-configuration '{
"Rules": [
{
"ID": "expire-logs",
"Filter": { "Prefix": "logs/" },
"Status": "Enabled",
"Expiration": { "Days": 30 },
"NoncurrentVersionExpiration": { "NoncurrentDays": 7 },
"AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 2 }
}
]
}'
View as Markdown