简体   繁体   English

无法通过 aws cli 创建 ECS 容量提供程序

[英]Unable to create a ECS capacity provider by aws cli

Creating AWS ECS Capacity Provider on command line and it reports error as below:在命令行上创建 AWS ECS 容量提供程序,它报告如下错误:

aws ecs create-capacity-provider --name="abc-perf3-$(date "+ %F-%H%M%S")" --auto-scaling-group-provider=abc-perf3 managedScaling=ENABLED managedTerminationProtection=ENABLED
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: managedTerminationProtection=ENABLED, managedScaling=ENABLED

I did try with -- option as well but that does not work either.我也尝试过--选项,但这也不起作用。

aws ecs create-capacity-provider --name="abc-perf3-$(date "+ %F-%H%M%S")" --auto-scaling-group-provider=abc-perf3 --managedScaling=ENABLED --managedTerminationProtection=ENABLED
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: --managedScaling=ENABLED, --managedTerminationProtection=ENABLED

I do not wish to use json file (json example given here, https://github.com/awsdocs/amazon-ecs-developer-guide/blob/97febdb027cd297d915c1a6ae14b813e671d0dcc/doc_source/tutorial-cluster-auto-scaling-cli.md )我不想使用 json 文件(这里给出的 json 示例, https://github.com/awsdocs/amazon-ecs-developer-guide/blob/97febdb027cd297d915c1a6ae14b813e671d0dcc/doc_source/tutorial-cluster-auto-scaling-cli.md

I want to create a capacity provider by passing arguments on command line but pass arguments on command line, how to achieve that?我想通过在命令行上传递参数但在命令行上传递参数来创建容量提供程序,如何实现?

PS: Update after I tried the answer. PS:尝试答案后更新。

Command below:命令如下:

aws ecs create-capacity-provider --name="abc-perf3-$(date "+ %F-%H%M%S")" --auto-scaling-group-provider="abc-perf3" managedScaling={status=ENABLED,targetCapacity=75}, managedTerminationProtection=DISABLE

Error message:错误信息:

Unknown options: managedScaling=targetCapacity=75,, managedTerminationProtection=DISABLED, managedScaling=status=ENABLED,

PPS : Update 2. Still not working. PPS :更新 2。仍然无法正常工作。

aws ecs create-capacity-provider --name="abc-dev3-$(date "+%F-%H%M%S")" --auto-scaling-group-provider "abc-dev3" managedScaling "{status=ENABLED,targetCapacity=75}",managedTerminationProtection=ENABLED
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: {status=ENABLED,targetCapacity=75},managedTerminationProtection=ENABLED, managedScaling

正确的命令如下:

aws ecs create-capacity-provider --name "abc-dev-$(date "+%F-%H%M%S")" --auto-scaling-group-provider "autoScalingGroupArn="arn:aws:autoscaling:ap-southeast-2:xxxxxxxxxxxxxxx:autoScalingGroup:xxxxxxxxxxxxxxxxxxxxxxxx:autoScalingGroupName/abc-dev",managedScaling={status=ENABLED,targetCapacity=75},managedTerminationProtection=DISABLED"

When using the AWS CLI, you can simplify the entry of json structures by using shorthand syntax .使用 AWS CLI 时,您可以使用速记语法来简化 json 结构的输入。

The AWS Command Line Interface (AWS CLI) can accept many of its option parameters in JSON format. AWS 命令​​行界面 (AWS CLI) 可以接受 JSON 格式的许多选项参数。 However, it can be tedious to enter large JSON lists or structures on the command line.但是,在命令行上输入大型 JSON 列表或结构可能很乏味。 To make this easier, the AWS CLI also supports a shorthand syntax that enables a simpler representation of your option parameters than using the full JSON format.为简化此操作,AWS CLI 还支持速记语法,与使用完整 JSON 格式相比,该语法可以更简单地表示您的选项参数。

The format is a comma-separated list of key-value pairs.格式是逗号分隔的键值对列表。

--option key1=value1,key2=value2,key3=value3

For your command the correct syntax would be something like:对于您的命令,正确的语法类似于:

aws ecs create-capacity-provider
 --name="abc-perf3-$(date "+ %F-%H%M%S")"
 --auto-scaling-group-provider managedScaling={status=string,targetCapacity=integer,minimumScalingStepSize=integer,maximumScalingStepSize=integer}, 
managedTerminationProtection=ENABLED

See Using Shorthand Syntax with the AWS CLI and AWS CLI Command Reference for ECS请参阅将速记语法与 AWS CLIAWS CLI 命令参考用于 ECS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM