Search code examples
aws-sdks3cmdceph

Can't set Bucket Lifecycle Configuration


Doing this (aws-sdk ruby gem):

  s3_client.put_bucket_lifecycle_configuration({
  bucket: bucket,
  lifecycle_configuration: {
    rules: [
      {
        id: "clean-temporary",
        status: "Disabled", # required, accepts Enabled, Disabled
        prefix: "temporary",
        filter: {
          prefix: "temporary",
        },
        expiration: {
          days: 1,
        },
      },
    ],
  },
})

I got an error: Aws::S3::Errors::BadRequest: [!]

According to Release Notes, my version (11) support it: S3 bucket lifecycle API has been added. Note that currently it only supports object expiration.

What am I doing wrong?

UPD: Tried the s3cmd, didn't help:

⇒  s3cmd -c s3cfg setlifecycle lifecycle_configuration.xml s3://my-new-bucket
ERROR: S3 error: 405 (MethodNotAllowed)
⇒  cat lifecycle_configuration.xml
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>test</ID><Status>Enabled</Status><Expiration><Days>1</Days></Expiration><Prefix></Prefix></Rule></LifecycleConfiguration>

Solution

  • Found a workaround:

    s3cmd -c s3cfg setlifecycle lifecycle_configuration.xml s3://my-new-bucket --signature-v2
    

    probably aws-sdk gem is not compatible with this feature.