How to migrate AWS CLI version 1 to 2

To Nha Notes | Dec. 10, 2022, 3:53 p.m.

This topic provides instructions for migrating from AWS CLI version 1 to AWS CLI version 2.

AWS CLI versions 1 and 2 use the same aws command name. If you have both versions installed, your computer uses the first one found in your search path. If you previously installed AWS CLI version 1, we recommend that you do one of the following to use AWS CLI version 2:

For information on breaking changes between version 1 and version 2, see New features and changes in AWS CLI version 2.

Replacing version 1 with version 2

Perform the following steps to replace AWS CLI version 1 with AWS CLI version 2.

To replace AWS CLI version 1 with AWS CLI version 2

  1. Prepare any existing scripts you have for the migration by confirming any breaking changes between version 1 and version 2 in New features and changes in AWS CLI version 2.

  2. Uninstall the AWS CLI version 1 by following the uninstall instructions for your operating system in Installing, updating, and uninstalling the AWS CLI version 1.

  3. Confirm that the AWS CLI is completely uninstalled by using the following command.

    $ aws --version

    Complete one of the following based on the output:

  4. Install the AWS CLI version 2 by following the appropriate install instructions for your operating system in Installing or updating the latest version of the AWS CLI.

To have both versions installed, use your operating system's ability to create a symbolic link (symlink) or alias with a different name for one of the two aws commands.

  1. Install the AWS CLI version 2 by following the appropriate install instructions for your operating system in Installing or updating the latest version of the AWS CLI.

  2. Use your operating system's ability to create a symlink or alias with a different name for one of the two aws commands, such as using aws2 for AWS CLI version 2. The following are symlink examples for AWS CLI version 2. Replace the PATH with your install location.

    • Linux and macOS
    • Windows command prompt

    You can use a symbolic link or alias on Linux and macOS.

    $ alias aws2='PATH'

 

How to uninstall the AWS CLI version 1

pip3 uninstall awscli
yum remove awscli

How to install the AWS CLI version 2

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install -i /usr/local/aws-cli -b /usr/local/bin --update
alias aws2=/usr/local/bin/aws

or

alias aws2=/usr/local/aws-cli/v2/current/bin/aws

References

https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration-instructions.html#cliv2-migration-instructions-migrate