Skip to main content

GetBucketLifecycle

Returns the lifecycle rules set on a bucket - the rules that tidy it up for you by expiring old versions and abandoned uploads (Lifecycle policies explains them). This is the older form of GetBucketLifecycleConfiguration: both send the same request and receive the same answer, and GetBucketLifecycleConfiguration is the better choice for new code, because its output includes each rule's prefix.

Deprecated

Amazon S3 deprecated GetBucketLifecycle in favour of GetBucketLifecycleConfiguration. STRG answers it, so older tools keep working, but a client parsing the response as GetBucketLifecycle output does not see each rule's prefix. The AWS SDK for JavaScript v3 does not offer this operation at all.

Good to know on STRG
  • A rule's prefix always comes back inside <Filter>, never as a top-level <Prefix>. Clients that parse the response as this operation's output skip <Filter>, so every rule looks as if it applies to the whole bucket.
  • A rule that expires current versions comes back as two rules: the rule itself, and a companion rule with the ID <id>_marker that clears away expired delete markers on the same prefix.
  • Rules count in days and use three actions: Expiration in days, NoncurrentVersionExpiration and AbortIncompleteMultipartUpload. Every object stays in one storage class, so there are no transitions, and there is no date-based expiration.
  • 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 backup or sync tool that checks a bucket's lifecycle rules before it runs, and was written against this operation, gets a well-formed answer and carries on.
  • A script that only needs to know whether rules exist - an audit that every bucket cleans up its old versions, say - can tell a 200 OK from 404 NoSuchLifecycleConfiguration either way.
  • Anything that needs the prefixes, such as a report of which part of a bucket each rule covers, is better served by GetBucketLifecycleConfiguration, which sends the same request and reads the prefix too.

Request​

GET /?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: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

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

Permissions​

The access key needs Read lifecycle rules (bucket-lifecycle:read). 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. Access keys has the full picture.

URI parameters​

NameTypeRequiredDescription
BucketStringYesThe bucket whose lifecycle rules are read.
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
x-amz-expected-bucket-ownerStringNoWelcome, with nothing to check: an access key only ever reaches its own account's buckets.

Request body​

None.

Response​

A bucket with lifecycle rules answers 200 OK with a LifecycleConfiguration document. A bucket without any answers 404 NoSuchLifecycleConfiguration.

Response headers​

NameDescription
x-amz-request-idThe request ID, handy for a support request.

Response body​

LifecycleConfiguration holds one Rule element per rule. The members this operation defines:

ElementTypeDescription
RuleContainerOne lifecycle rule. Repeated.
Rule/IDStringThe rule's ID, up to 255 characters: the one set with PutBucketLifecycleConfiguration, a generated one for a rule added in the dashboard, or <id>_marker for a companion rule.
Rule/PrefixStringNever returned. The prefix is in Rule/Filter/Prefix, which this operation's output does not define; GetBucketLifecycleConfiguration reads it.
Rule/StatusStringAlways Enabled: every rule STRG stores is active.
Rule/Expiration/DaysIntegerDays after an object is uploaded until its current version becomes a previous version.
Rule/Expiration/ExpiredObjectDeleteMarkerBooleantrue on a companion rule: a delete marker with no versions left behind it is removed.
Rule/Expiration/DateTimestampNever returned: rules count in days.
Rule/NoncurrentVersionExpiration/NoncurrentDaysIntegerDays after a version becomes a previous version until it is deleted permanently.
Rule/NoncurrentVersionExpiration/NewerNoncurrentVersionsIntegerNever returned: previous versions expire by age alone.
Rule/AbortIncompleteMultipartUpload/DaysAfterInitiationIntegerDays after a multipart upload starts until it is aborted if still incomplete.
Rule/TransitionContainerNever returned: STRG has one storage class.
Rule/NoncurrentVersionTransitionContainerNever returned, for the same reason.

The document as sent, for a rule on logs/ that uses all three actions:

<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Rule>
<ID>expire-logs</ID>
<Filter>
<Prefix>logs/</Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration>
<Days>30</Days>
</Expiration>
<NoncurrentVersionExpiration>
<NoncurrentDays>7</NoncurrentDays>
</NoncurrentVersionExpiration>
<AbortIncompleteMultipartUpload>
<DaysAfterInitiation>2</DaysAfterInitiation>
</AbortIncompleteMultipartUpload>
</Rule>
<Rule>
<ID>expire-logs_marker</ID>
<Filter>
<Prefix>logs/</Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration>
<ExpiredObjectDeleteMarker>true</ExpiredObjectDeleteMarker>
</Expiration>
</Rule>
</LifecycleConfiguration>

A client reading this as GetBucketLifecycle output gets both rules, without their prefix.

Errors​

The answers this operation can give, and the situation behind each:

CodeHTTP statusWhen
NoSuchLifecycleConfiguration404The bucket has no lifecycle rules.
NoSuchBucket404The bucket does not exist, it is in a region other than the endpoint's, or the account stores nothing in this endpoint's region.
AccessDenied403The access key does not hold Read 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, in which case the same request works shortly after.
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.
NotImplemented501The request carries a query parameter this operation does not take.
SlowDown503Too many requests in a short time. The answer carries Retry-After, and the AWS SDKs retry on their own.
ServiceUnavailable503A temporary failure. The AWS SDKs retry it on their own.

Differences from Amazon S3​

AspectAmazon S3STRG
Rule prefixReturned as a top-level Prefix for a rule set with oneAlways inside Filter, which this operation's parsers skip. GetBucketLifecycleConfiguration shows the prefixes.
Expiration of current versionsOne ruleTwo rules: the rule and its <id>_marker companion, which clears away expired delete markers
ActionsTransitions, date-based expiration, NewerNoncurrentVersionsExpiration in days, NoncurrentVersionExpiration in days and AbortIncompleteMultipartUpload - one storage class, so no transitions
Bucket in another region301 redirect with x-amz-bucket-region404 NoSuchBucket. The bucket's own regional endpoint answers for it.
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​

Reading the lifecycle rules of my-bucket:

aws s3api get-bucket-lifecycle \
--bucket my-bucket \
--endpoint-url https://s3.eu-central-1.strg.com \
--region eu-central-1

The output lists each rule without its prefix. aws s3api get-bucket-lifecycle-configuration shows the same rules with their prefixes.

View as Markdown