S3 Put Lifecycle Configuration
    • Dark
      Light

    S3 Put Lifecycle Configuration

    • Dark
      Light

    Article summary

    PUThttps://s3.<your-region>.backblazeb2.com/<your-bucket-name>?lifecycle

    Creates a new lifecycle configuration for a bucket or replaces an existing lifecycle configuration. This operation will overwrite an existing lifecycle configuration, so if you want to retain any configuration details, they must be included in the new lifecycle configuration. For information about lifecycle configuration, see Lifecycle Rules.

    AUTHORIZATION AWS Signature

    This request is using AWS Signature from collection Backblaze B2 Cloud Storage S3 Compatible API.

    URI REQUEST PARAMETERS

    Bucket

    Required.

    The name of the bucket for which to set the lifecycle configuration. The bucket must have versioning enabled.

    x-amz-expected-bucket-owner

    The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

    x-amz-sdk-checksum-algorithm

    Indicates the algorithm used to create the checksum for the request when you use the SDK. When you send this header, there must be a corresponding x-amz-checksum or x-amz-trailer header sent. Otherwise, the request fails with the HTTP status code 400 Bad Request.

    Valid Values: CRC32 | CRC32C | SHA1 | SHA256 | CRC64NVME

    REQUEST BODY

    LifecycleConfiguration

    Required.

    Root level tag for the LifecycleConfiguration parameters.

    Rule

    Required.

    A lifecycle rule for individual objects in the bucket. An S3 Lifecycle configuration can have up to 1,000 rules.

    B2 COMPATIBILITY NOTES

    S3 lifecycle rules are mapped to Backblaze B2 lifecycle rules as follows:

    S3 Lifecycle Action

    B2 Lifecycle Action

    Expiration

    hide

    NoncurrentVersionExpiration

    delete

    AbortIncompleteMultipartUpload

    daysFromStartingToCancelingUnfinishedLargeFiles

    Supported Features

    The following S3 lifecycle rule features are supported:

    • Expiration with Days - Hide the current version of objects after a specified number of days.

    • Expiration with ExpiredObjectDeleteMarker set to true - Remove orphan delete markers.

    • NoncurrentVersionExpiration with NoncurrentDays - Permanently delete noncurrent object versions after a specified number of days.

    • AbortIncompleteMultipartUpload with DaysAfterInitiation - Abort incomplete multipart uploads after a specified number of days.

    • Filter with Prefix - Apply rules to objects matching a key name prefix.

    • ID - Optional identifier for the rule.

    • Status set to Enabled - Rules must be enabled.

    Unsupported Features

    The following S3 lifecycle rule features are not supported and will return a 400 Bad Request error:

    • Transition and NoncurrentVersionTransition - Storage class transitions are not supported.

    • Expiration with Date - Date-based expiration is not supported. Use Days instead.

    • ExpiredObjectDeleteMarker set to false - B2 always removes orphan delete markers.

    • NewerNoncurrentVersions - Keeping a specific number of noncurrent versions is not supported.

    • Status set to Disabled - Disabled rules are not supported.

    • Filter sub-elements other than Prefix - Tag-based filtering (Tag), object size filtering (ObjectSizeGreaterThan, ObjectSizeLessThan), and And combinations are not supported.

    • Overlapping prefix filters - Rules with overlapping prefixes are not supported.

    • Top-level Prefix (deprecated) - Use Filter with Prefix instead.

    • Unversioned or versioning-suspended buckets - Only versioning-enabled buckets are supported.

    Expiration Rule Pairing Requirement

    B2 lifecycle rules always remove orphan delete markers (delete markers with no remaining object versions). Because of this behavior, S3 Expiration rules must be defined in pairs for each prefix:

    1. One rule with Expiration specifying the number of Days to wait before hiding the current version.

    2. One rule with the same prefix that includes Expiration with ExpiredObjectDeleteMarker set to true.

    These two S3 rules are stored as a single corresponding B2 lifecycle rule.

    Example Request

    Request Body

    <?xml version="1.0" encoding="UTF-8"?>
    <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
       <Rule>
          <ID>expire-logs-after-30-days</ID>
          <Filter>
             <Prefix>logs/</Prefix>
          </Filter>
          <Status>Enabled</Status>
          <Expiration>
             <Days>30</Days>
          </Expiration>
       </Rule>
       <Rule>
          <ID>expire-logs-delete-markers</ID>
          <Filter>
             <Prefix>logs/</Prefix>
          </Filter>
          <Status>Enabled</Status>
          <Expiration>
             <ExpiredObjectDeleteMarker>true</ExpiredObjectDeleteMarker>
          </Expiration>
       </Rule>
       <Rule>
          <ID>delete-old-versions-after-90-days</ID>
          <Filter>
             <Prefix>documents/</Prefix>
          </Filter>
          <Status>Enabled</Status>
          <NoncurrentVersionExpiration>
             <NoncurrentDays>90</NoncurrentDays>
          </NoncurrentVersionExpiration>
       </Rule>
       <Rule>
          <ID>abort-incomplete-uploads</ID>
          <Filter>
             <Prefix></Prefix>
          </Filter>
          <Status>Enabled</Status>
          <AbortIncompleteMultipartUpload>
             <DaysAfterInitiation>7</DaysAfterInitiation>
          </AbortIncompleteMultipartUpload>
       </Rule>
    </LifecycleConfiguration>


    Example Response

    200 OK

    HTTP/1.1 200 OK
    x-amz-id-2: r+qR7+nhXtJDDIJ0JJYcd+1j5nM/rUFiiiZ/fNbDOsd3JUE8NWMLNHXmvPfwMpdc
    x-amz-request-id: 9E26D08072A8EF9E
    Date: Wed, 14 May 2014 02:11:22 GMT
    Content-Length: 0
    Server: AmazonS3


    400 Bad Request

    HTTP/1.1 400 Bad Request
    <?xml version="1.0" encoding="UTF-8"?>
    <Error>
       <Code>NotSupported</Code>
       <Message>The specified lifecycle configuration feature is not supported.</Message>
    </Error>



    Was this article helpful?