We’re excited to announce the v2.0.0 GA release of the AWS CLI version 2 (v2).
AWS CLI v2 builds on AWS CLI v1 and includes a number of features and enhancements based on community feedback.
The AWS CLI v2 offers several new features including improved installers, new configuration options such as AWS Single Sign-On (SSO), and various interactive features.
New installation mechanisms
AWS CLI v2 provides pre-built binaries for Windows, Linux, and macOS. You no longer need to have Python installed in order to use the AWS CLI. You don’t have to worry about compatible Python versions, virtual environments, or conflicting python packages. On Windows we provide an MSI installer and on macOS we provide a .pkg installer. See our installation instructions for more information on installing AWS CLI v2.
AWS configuration mechanisms
AWS CLI v2 introduces several new mechanisms for configuring credentials. We’ve added a new
aws configure import command to import credentials from the .csv files generated in the AWS Console.
$ aws configure import --csv file://path/to/creds.csv
We’ve also added support for a new
aws configure wizard command that provides a guided walkthrough of configuring AWS credentials. In addition to these commands, AWS CLI v2 supports configuring and using credentials through AWS SSO using the new
aws configure sso command. It will ask you a series of questions to help you configure the AWS CLI.
$ aws configure sso SSO start URL [None]: https://d-0123456790.awsapps.com/start SSO Region [None]: us-west-2 Attempting to automatically open the SSO authorization page in your default browser. If the browser does not open or you wish to use a different device to authorize this request, open the following URL: https://device.sso.us-west-2.amazonaws.com/ Then enter the code: ABCD-EFGH Successully logged into Start URL: https://d-1234567890.awsapps.com/start There are 2 AWS accounts available to you. Using the account ID 123456789012 There are 2 roles available to you. Using the role name "readOnly" CLI default client Region [None]: us-west-2 CLI default output format [None]: json CLI profile name [readOnly-123456789012]: my-sso-profile To use this profile, specify the profile name using --profile, as shown: aws s3 ls --profile my-sso-profile
We wrote a blog post that shows you step by step how to use AWS SSO with AWS CLI v2. The “Introduction to the AWS CLI v2” session for re:Invent 2019 also includes a demo of using the AWS CLI v2 and AWS SSO.
One of the major themes for AWS CLI v2 was including more interactive features to help customers. The AWS CLI is used for both automated scripting tasks as well interactive usage, and we wanted to include features that help users when they’re running CLI commands interactively in a terminal. Some of the new interactive features include server side auto-completion, the
--cli-auto-prompt command, and wizards.
Server side auto-completion
In AWS CLI v1, you could use the
aws_completer command for tab-completion of command and parameter names. For example, after configuring the
aws command to use the auto-completer, you could auto-complete like this:
$ complete -C aws_completer aws $ aws cloud<TAB> cloud9 cloudformation cloudhsm cloudsearch cloudtrail clouddirectory cloudfront cloudhsmv2 cloudsearchdomain cloudwatch
In AWS CLI v2, we’ve updated the auto-completer to complete service side resource names. For example, we can now auto-complete Amazon DynamoDB table names:
$ aws dynamodb update-table --table-name MyTable<TAB> MyTable1 MyTable2
Auto-completion helps you input CLI parameters more efficiently, but sometimes you’re not sure which parameters you want to provide. The new
--cli-auto-prompt feature can help you. You can add this parameter to any built-in CLI command, and the CLI will guide you through entering parameter values.
First, it will prompt you for all required parameters.
Once you’ve entered all required parameters, you’ll be presented with a list of optional parameters. The first sentence of the documentation is also included for each parameter.
Once you’ve entered all the parameters you want, you can select
Parameter input finished, and you’ll have an option to either have the AWS CLI invoke the command or print the command for you.
The new wizards feature in AWS CLI v2 guides you through managing various AWS resources. They are a higher level abstraction than
--cli-auto-prompt and typically combine multiple AWS API calls together in order to create, update, or delete AWS resources. They are similiar to the getting started workflows in the AWS console. We’ve added wizards to an initial set of AWS services. To access these wizards you can run
aws <service-name> wizard <wizard-name>.
We’ll look at an example for creating a new DynamoDB table. First we’ll run the
aws dynamodb wizard new-table command and we’ll be asked a series of questions. In the screenshot below we’re being asked to select the type of the primary key for our table.
Wizards also support querying for existing resources when prompting you for data. In the next screenshot we’re being asked for our server-side encryption settings, and we select “KMS – Customer managed CMK”.
Once we select that option, the wizard will query for existing KMS keys we can use and prompt us to select a key. In this example I only have a single KMS key available.
Once we’ve answered all the questions, the wizard will create our DynamoDB table.
We’ve added wizards for the
For the full list of features, enhancements, and bugfixes, see the AWS CLI v2 changelog. While AWS CLI v2 is mostly backwards compatible with AWS CLI v1, there are some backwards incompatible changes which are listed in our AWS CLI v2 migration guide. Our user guide has more information on using the AWS CLI.
You can also create feature requests and file issues on our GitHub repository. We look forward to your feedback about AWS CLI v2.
from AWS Developer Blog: https://aws.amazon.com/blogs/developer/aws-cli-v2-is-now-generally-available/