aws:error:参数操作:put-bucket-lifecycle-configuration

Ash*_*rpe 0 amazon-s3 amazon-web-services aws-cli

针对put-bucket-lifecycle-configuration获取以下错误:

[root@ADM-PROD-OMNI noc-scripts]# aws s3api put-bucket-lifecycle-configuration --bucket noc-try --lifecycle-configuration  lifecycle.json
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument operation: Invalid choice, valid choices are:

abort-multipart-upload                   | complete-multipart-upload
copy-object                              | create-bucket
create-multipart-upload                  | delete-bucket
delete-bucket-cors                       | delete-bucket-lifecycle
delete-bucket-policy                     | delete-bucket-replication
delete-bucket-tagging                    | delete-bucket-website
delete-object                            | delete-objects
get-bucket-acl                           | get-bucket-cors
get-bucket-lifecycle                     | get-bucket-location
get-bucket-logging                       | get-bucket-notification
get-bucket-notification-configuration    | get-bucket-policy
get-bucket-replication                   | get-bucket-request-payment
get-bucket-tagging                       | get-bucket-versioning
get-bucket-website                       | get-object
get-object-acl                           | get-object-torrent
head-bucket                              | head-object
list-buckets                             | list-multipart-uploads
list-object-versions                     | list-objects
list-parts                               | put-bucket-acl
put-bucket-cors                          | put-bucket-lifecycle
put-bucket-logging                       | put-bucket-notification
put-bucket-notification-configuration    | put-bucket-policy
put-bucket-replication                   | put-bucket-request-payment
put-bucket-tagging                       | put-bucket-versioning
put-bucket-website                       | put-object
put-object-acl                           | restore-object
upload-part                              | upload-part-copy
wait                                     | help
Run Code Online (Sandbox Code Playgroud)

get-bucket-lifecycle正在运行这意味着我的aws配置了:

[root@ADM-PROD-OMNI noc-scripts]# aws s3api get-bucket-lifecycle --bucket 4sm-wrapup
RULES    clear multipart failed files           Enabled

**OR**

[root@ADM-PROD-OMNI noc-scripts]# aws s3api get-bucket-lifecycle --bucket noc-try

A client error (NoSuchLifecycleConfiguration) occurred when calling the GetBucketLifecycle operation: The lifecycle configuration does not exist
Run Code Online (Sandbox Code Playgroud)

还尝试过:

 [root@ADM-PROD-OMNI noc-scripts]# aws s3api put-bucket-lifecycle --bucket noc-try --lifecycle-configuration  lifecycle.json

    Error parsing parameter '--lifecycle-configuration': Expected: '=', received: '.' for input:
    lifecycle.json
             ^
Run Code Online (Sandbox Code Playgroud)

请告诉我这里有什么问题?

Jim*_* P. 5

在你的第一个例子中很明显,"put-bucket-lifecycle-configuration"方法不存在,你需要使用"put-bucket-lifecycle",你说你也尝试过并收到了不同的错误.

不同的错误是好的!

新错误表明在调用.json配置文件和/或不正确的结构化JSON时语法不正确.

以下是关于"put-bucket-lifecycle"的文档:put-bucket-lifecycle

以下是调用.json配置文件的示例:

aws s3api put-bucket-lifecycle --bucket my-bucket --lifecycle-configuration file://lifecycle.json
Run Code Online (Sandbox Code Playgroud)

以下是JSON文件的示例:

{
  "Rules": [
    {
      "ID": "Move to Glacier after sixty days (objects in logs/2015/)",
      "Prefix": "logs/2015/",
      "Status": "Enabled",
      "Transition": {
        "Days": 60,
        "StorageClass": "GLACIER"
      }
    },
    {
      "Expiration": {
        "Date": "2016-01-01T00:00:00.000Z"
      },
      "ID": "Delete 2014 logs in 2016.",
      "Prefix": "logs/2014/",
      "Status": "Enabled"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

下面的JSON文件在随后的屏幕截图中进行了测试和工作:

{
    "Rules": [
        {
          "ID": "multipart-upload-rule",
          "Prefix": "noc-try",
          "Status": "Enabled",
          "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 3 }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

CLI命令使用上面的JSON文件创建生命周期配置:

aws s3api put-bucket-lifecycle --bucket testbucket1478921 --lifecycle-configuration file://c:/tmp/test.json
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述在此输入图像描述在此输入图像描述