无法通过AWS CLI创建ECS容量提供商

时间:2020-01-28 01:46:02

标签: amazon-web-services amazon-ecs

在命令行上创建AWS ECS Capacity Provider并报告如下错误:

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

我也尝试了-选项,但这也不起作用。

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

我不希望使用json文件(此处给出了json示例,https://github.com/awsdocs/amazon-ecs-developer-guide/blob/97febdb027cd297d915c1a6ae14b813e671d0dcc/doc_source/tutorial-cluster-auto-scaling-cli.md

我想通过在命令行上传递参数但在命令行上传递参数来创建容量提供程序,如何实现?

附言:我尝试回答后进行了更新。

下面的命令:

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

错误消息:

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

P.P.S:更新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

2 个答案:

答案 0 :(得分:1)

起作用的正确命令如下:

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"

答案 1 :(得分:0)

使用AWS CLI时,您可以使用速记语法简化json结构的输入。

AWS命令行界面(AWS CLI)可以接受许多JSON格式的选项参数。但是,在命令行上输入大型JSON列表或结构可能很麻烦。为了简化此操作,AWS CLI还支持一种简写语法,该语法比使用完整的JSON格式更易于表示您的选项参数。

格式是键值对的逗号分隔列表。

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

对于您的命令,正确的语法应类似于:

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

请参见Using Shorthand Syntax with the AWS CLIAWS CLI Command Reference for ECS