简体   繁体   中英

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 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 )

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.

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.

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 .

The AWS Command Line Interface (AWS CLI) can accept many of its option parameters in JSON format. However, it can be tedious to enter large JSON lists or structures on the command line. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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