【问题标题】:aws: error: argument operation: put-bucket-lifecycle-configurationaws:错误:参数操作:put-bucket-lifecycle-configuration
【发布时间】:2016-09-05 15:18:20
【问题描述】:

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

但是

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

也试过了:

 [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
             ^

请告诉我这里出了什么问题?

【问题讨论】:

标签: amazon-web-services amazon-s3 aws-cli


【解决方案1】:

在您的第一个示例中,很明显“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

以下是 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"
    }
  ]
}

下面的 JSON 文件经过测试,如后续屏幕截图所示:

{
    "Rules": [
        {
          "ID": "multipart-upload-rule",
          "Prefix": "noc-try",
          "Status": "Enabled",
          "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 3 }
        }
    ]
}

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

aws s3api put-bucket-lifecycle --bucket testbucket1478921 --lifecycle-configuration file://c:/tmp/test.json

【讨论】:

  • 我不想搬到冰川!我希望它清除多部分失败的文件,即: clear multipart failed filesS3 buckets/Enabled30
  • [root@ADM-PROD-OMNI noc-scripts]# aws s3api put-bucket-lifecycle --bucket noc-try --lifecycle-configuration file://lifecycle.json substring not found 得到此 jason 文件的此错误:clear-multipart-failed-fileswhole bucket/Enabled3
  • 收到此错误:[root@ADM-PROD-OMNI noc-scripts]# aws s3api put-bucket-lifecycle --bucket noc-try --lifecycle-configuration file://lifecycle1.json参数验证失败:LifecycleConfiguration.Rules[0] 中的未知参数:“AbortIncompleteMultipartUpload”,必须是以下之一:Expiration、ID、Prefix、Status、Transition、NoncurrentVersionTransition、NoncurrentVersionExpiration
  • 对于以下 json 文件:[root@ADM-PROD-OMNI noc-scripts]# cat lifecycle1.json { "Rules": [ { "ID": "clear-multipart-failed-files" , "Prefix": "noc-try", "Status": "Enabled", }, "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 30 } } ] }
  • 如原始答案所述,您的尝试有 2 个问题。您在 CLI 命令提示符下使用了错误的方法,并且您的 JSON 文件格式不正确。原始答案已更新,包括正确的 CLI 命令语法和正确的 JSON 格式。从屏幕截图中可以看出,它已经过测试,并且可以正常工作!
猜你喜欢
  • 2020-08-05
  • 1970-01-01
  • 1970-01-01
  • 2023-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-26
  • 2021-11-01
相关资源
最近更新 更多