无法设置Bucket Lifecycle Configuration

时间:2017-02-21 16:02:46

标签: aws-sdk s3cmd ceph

这样做(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,
        },
      },
    ],
  },
})

我收到了错误:Aws::S3::Errors::BadRequest: [!]

根据发行说明,我的版本(11)支持它: 添加了S3存储桶生命周期API。请注意,目前它仅支持对象过期。

我做错了什么?

UPD: 尝试s3cmd,没有帮助:

⇒  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>

1 个答案:

答案 0 :(得分:0)

找到了解决方法:

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

可能aws-sdk gem与此功能不兼容。