cssamazon-web-servicesamazon-s3s3cmd

How to use ObjectSizeGreaterThan and ObjectSizeLessThan xml tags for AWS S3 command 'PutBucketLifeCycleConfiguration"?


Trying with a json input like this:

{
  "Rules": [
    {
      "Expiration": {
        "Date": "2023-01-01T00:00:00.000Z"
      },
      "ID": "id1",
      "Filter": {
          "And": {
            "Tags": [
              {
                "Key": "k1",
                "Value": "k1val1"
              },
              {
                "Key": "k1u",
                "Value": "k1vadl1"
              }
            ],
            "ObjectSizeGreaterThan": 100,
            "ObjectSizeLessThan": 1000
          }
      },
      "Status": "Enabled"
    }
  ]
}

However, I am getting an error like this from the aws client:

Parameter validation failed:
Unknown parameter in LifecycleConfiguration.Rules[0].Filter.And: "ObjectSizeGreaterThan", must be one of: Prefix, Tags

Any idea why I get this error and how to correct it?


Solution

  • This seems to be working but only with the latest cli version aws-cli/2.7.30

    I am getting the same error on aws-cli/1.19.39

    {
        "Rules": [
          {
            "Expiration": {
                "Date": "2024-01-01T00:00:00.000Z"
            },
            "ID": "123",
            "Filter": {
              "And": {
                "Prefix": "sricli",
                "Tags": [
                  {
                    "Key": "ke",
                    "Value": "k1"
                  },
                  {
                    "Key": "je",
                    "Value": "k2"
                  }
                ],
                "ObjectSizeGreaterThan": 102400,
                "ObjectSizeLessThan": 204800
              }
            },
            "Status": "Enabled"
          }
        ]
      }
    

    Sri