Command structure in the Amazon CLI - Amazon Command Line Interface
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.

Command structure in the Amazon CLI

This topic covers how Amazon Command Line Interface (Amazon CLI) command is structured, and how to use wait commands.

Command structure

The Amazon CLI uses a multipart structure on the command line that must be specified in this order:

  1. The base call to the aws program.

  2. The top-level command, which typically corresponds to an Amazon service supported by the Amazon CLI.

  3. The subcommand that specifies which operation to perform.

  4. General Amazon CLI options or parameters required by the operation. You can specify these in any order as long as they follow the first three parts. If an exclusive parameter is specified multiple times, only the last value applies.

$ aws <command> <subcommand> [options and parameters]

Parameters can take various types of input values, such as numbers, strings, lists, maps, and JSON structures. What is supported is dependent upon the command and subcommand you specify.

Amazon S3

The following example lists all of your Amazon S3 buckets.

$ aws s3 ls 2018-12-11 17:08:50 amzn-s3-demo-bucket1 2018-12-14 14:55:44 amzn-s3-demo-bucket2

For more information on the Amazon S3 commands, see aws s3 in the Amazon CLI Command Reference.

Amazon CloudFormation

The following create-change-setcommand example changes the cloudformation stack name to my-change-set.

$ aws cloudformation create-change-set --stack-name my-stack --change-set-name my-change-set

For more information on the Amazon CloudFormation commands, see aws cloudformation in the Amazon CLI Command Reference.

Wait commands

Some Amazon services have wait commands available. Any command that uses aws wait usually waits until a command is complete before it moves on to the next step. This is especially useful for multipart commands or scripting, as you can use a wait command to prevent moving to subsequent steps if the wait command fails.

The Amazon CLI uses a multipart structure on the command line for the wait command that must be specified in this order:

  1. The base call to the aws program.

  2. The top-level command, which typically corresponds to an Amazon service supported by the Amazon CLI.

  3. The wait command.

  4. The subcommand that specifies which operation to perform.

  5. General CLI options or parameters required by the operation. You can specify these in any order as long as they follow the first three parts. If an exclusive parameter is specified multiple times, only the last value applies.

$ aws <command> wait <subcommand> [options and parameters]

Parameters can take various types of input values, such as numbers, strings, lists, maps, and JSON structures. What is supported is dependent upon the command and subcommand you specify.

Note

Not every AWS service supports wait commands. See the Amazon CLI reference guide to see if your service supports wait commands.

Amazon CloudFormation

The following wait change-set-create-complete command examples pauses and resumes only after it can confirm that the my-change-set change set in the my-stack stack is ready to run.

$ aws cloudformation wait change-set-create-complete --stack-name my-stack --change-set-name my-change-set

For more information on the Amazon CloudFormation wait commands, see wait in the Amazon CLI Command Reference.

Amazon CodeDeploy

The following wait deployment-successful command examples pauses until the d-A1B2C3111 deployment completes successfully.

$ aws deploy wait deployment-successful --deployment-id d-A1B2C3111

For more information on the Amazon CodeDeploy wait commands, see wait in the Amazon CLI Command Reference.