How to upgrade AWS CLI to the latest version?

116,715

Solution 1

From http://docs.aws.amazon.com/cli/latest/userguide/installing.html#install-with-pip

To upgrade an existing AWS CLI installation, use the --upgrade option:

pip install --upgrade awscli

Solution 2

On Linux and MacOS X, here are the three commands that correspond to each step:

$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
$ unzip awscli-bundle.zip
$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Solution 3

This does not work:

pip install --upgrade awscli

This worked fine on Ubuntu 14.04( no need to reboot also .. You would have to first install pip3 ):

pip3 install --upgrade awscli

Solution 4

For Ubuntu 16.04 I used parts of the other answers and comments and just reloaded bash instead of rebooting.

I installed the aws-cli using apt so I removed that first:

sudo apt-get remove awscli

Then I could pip install (I chose to use sudo to install globally with pip2):

sudo pip install -U awscli

Since I was doing this on a server I didn't want to reboot it, but reloading bash did the trick:

source ~/.bashrc

At this point I could use the new version of aws cli

aws --version

Solution 5

Update: Upgrade instance using AWS CLI v1 to AWS CLI v2:

This question and answer was initially created when there was only an AWS CLI v1. There is now a AWS CLI v2. The installation instructions for the AWS CLI v2 can be found here.

The new AWS CLI v2 has different installation instructions based on whether your EC2 instance is using Linux x86 (64-bit) or Linux ARM architecture.

To upgrade to AWS CLI v2, on an EC2 instance using Linux ARM, I had to issue the following commands:

rm -rf /bin/aws
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install -i /usr/local/aws -b /bin

Subsequently test your AWS CLI version by executing: aws --version

For the Linux x86 (64-bit) architecture I'm hoping the commands are the same except for replacing the curl command with the following: (as per the installation instructions)

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

The AMI I used was the most recent one currently available and it was still using the AWS CLI v1. In the future if AWS starts packaging AWS CLI v2 with their AMIs this answer might require an update.


Original answer: Upgrade instance using AWS CLI v1 to use the most recent version of AWS CLI v1:

If you are having trouble installing the AWS CLI using pip you can use the "Bundled Installer" as documented here.

The steps discussed there are as follows:

$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
$ unzip awscli-bundle.zip
$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Check your AWS CLI version subsequently as a sanity-check that everything executed correctly:

$ aws --version

If the AWS CLI didn't update to the latest version as expected maybe the AWS CLI binaries are located somewhere else as the previously-given commands assume.

Determine where AWS CLI is being executed from:

$ which aws

In my case, AWS CLI was being executed from /bin/aws, so I had to install the "Bundled Installer" using that location as follows:

$ sudo ./awscli-bundle/install -i /user/local/aws -b /bin/aws
Share:
116,715

Related videos on Youtube

Borealis
Author by

Borealis

Updated on February 22, 2022

Comments

  • Borealis
    Borealis about 2 years

    I recently noticed that I am running an old version of AWS CLI that is lacking some functionality I need:

    $aws --version
    aws-cli/1.2.9 Python/3.4.3 Linux/3.13.0-85-generic
    

    How can I upgrade to the latest version of the AWS CLI (1.10.24)?

    Edit:

    Running the following command fails to update AWS CLI:

    $ pip install --upgrade awscli
    Requirement already up-to-date: awscli in /usr/local/lib/python2.7/dist-packages
    Cleaning up...
    

    Checking the version:

    $ aws --version
    aws-cli/1.2.9 Python/3.4.3 Linux/3.13.0-85-generic
    
    • Darren Reid
      Darren Reid over 6 years
      I had this same situation and was caused by the aws cli being originally installed via apt-get install awscli. Solution was to remove it first (apt-get remove awscli) and follow pip install answers below.
    • NKM
      NKM over 5 years
      I did (apt-get remove awscli) but then after following (pip install...) commands I can't find the awscli executable. The output of (pip install ...) says successfully installed.
    • NKM
      NKM over 5 years
      If I don't use "--user" option in pip install then I could find awscli executable under /usr/local/bin (I am on Debian Jessie). But with --user option the exec is not available in ~/.local or in any of the python installation package folders (dist-package or site-package).
  • Borealis
    Borealis about 8 years
    I get the following message: Requirement already up-to-date: awscli in /usr/local/lib/python2.7/dist-packages. Although when I run aws --version, I get aws-cli/1.2.9 Python/3.4.3 Linux/3.13.0-85-generic.
  • RaviTezu
    RaviTezu about 8 years
    Try pip3 install --upgrade awscli
  • Borealis
    Borealis about 8 years
    Running sudo pip3 install --upgrade awscli and a reboot did the trick. Thanks for the help.
  • JoeTidee
    JoeTidee over 7 years
    Just a reboot is required after installing aws cli.
  • toddkaufmann
    toddkaufmann over 7 years
    I can't believe a reboot is required, but in this case it was faster to reboot my vm than find an alternative [that 'reboot voodoo' is for windows].
  • dannyman
    dannyman almost 7 years
    This may require: apt-get install python3-pip Either command works equally well for me on Ubuntu 14.04.
  • B M
    B M over 6 years
    updating via pip did not work for me - deleting aws and re-installing it this way did work.
  • Lynn Langit
    Lynn Langit over 6 years
    On Mac OS, I had to run sudo pip install --upgrade awscli for my machine to be able to uninstall the previous version of the awscli (after the initial upgrade ran successfully)
  • zed
    zed over 6 years
    If PyYAML failed you while installing: pip uninstall awscli, then sudo apt-get install python-dev and pip install awscli again.
  • Pratik Patel
    Pratik Patel almost 6 years
    Thanks for source ~/.bashrc step.:)
  • Kannaiyan
    Kannaiyan over 5 years
    You saved my day. AWS is getting poor on its documentation.
  • Remigiusz
    Remigiusz almost 5 years
    For me helped going sudo su first.
  • Kostanos
    Kostanos almost 5 years
    you don't need to reboot, just enter to another terminal, or restart the current one
  • hit3k
    hit3k over 4 years
    this option worked for me as I needed to upgrade /usr/local/aws ( not /home/ubuntu/.local/bin/aws ) to be used by jenkins user
  • Chad Grant
    Chad Grant over 4 years
    using the bundled installer somehow makes the resulting docker image LARGER than using pip ... mind blowing
  • Dick Chesterwood
    Dick Chesterwood over 4 years
    It may be necessary to open a new shell after installing - for some reason "aws" doesn't point to the new install until exiting and restarting.
  • Dick Chesterwood
    Dick Chesterwood over 4 years
    The documentation of AWS is indeed deteriorating rapidly. This is the correct answer, I can't understand why the questioner accepted an answer which they'd clearly stated in their edit didn't work - the pip packages are often behind the current latest which is a problem when using new stuff like EKS. Note: I had to exit the shell and log back in for the aws command to pick up the new version. No idea why.
  • Ankur Bhatia
    Ankur Bhatia almost 4 years
    I now have aws and aws2 in my systems. How do I get rid of aws and rename my aws2 as aws?
  • AUR
    AUR almost 4 years
    on my jenkins machine I didn't want to explicitly uninstall the cli, so I used this method and worked like a charm!
  • Rahul
    Rahul about 3 years
    Until unless used for a specific purpose, common day to day operations could easily be handled with Cloud shell
  • Peter Wiseman
    Peter Wiseman about 3 years
    Instead of reboot or starting another shell, you can run "hash -r" to clear the remembered utility locations. Or "hash aws" to reset just the remembered aws executable location.