Installing aws-cli on Ubuntu 18.04 LTS

There are a number of ways to install the AWS command line tools. The below method used to be my preferred one for Ubuntu 18.04 LTS.  However a recent update broke my awscli installation using this method.  As such I now prefer the PIP method shown below.

Ubuntu Repository

[[email protected] ~]$ sudo apt install awscli

Check that was successful with:

[[email protected] ~]$ aws --version
aws-cli/1.14.44 Python/3.6.7 Linux/4.15.0-50-generic botocore/1.8.48

Configure aws-cli to use your AWS credentials:

[[email protected] ~]$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: eu-west-1
Default output format [None]: json

You can test your AWS credentials with the below command.

[[email protected] ~]$ aws sts get-caller-identity
{
    "Account": "903503371367", 
    "UserId": "AKIAIOSFODNN7EXAMPLE", 
    "Arn": "arn:aws:iam::903503371367:user/andy"
}

It should display your users details if you are authenticated.

PIP

If using this method, its best to install it into a virtual environment. Follow this guide first if you don’t already have one setup.

First edit ~/.bashrc to include ~/.local/bin on the class path:

[[email protected] ~]$ vim ~/.bashrc

Add:

export PATH=~/.local/bin:$PATH

Then load in the change:

[[email protected] ~]$ source ~/.bashrc

Create a new project called awscli and enter the virtual environment:

[[email protected] ~]$ mkproject -p /usr/bin/python3 awscli

Install using pip3:

(awscli) [email protected]:~/Devel/awscli$ sudo pip3 install awscli --upgrade --user

For some reason I also had to issue:

(awscli) [email protected]:~/Devel/awscli$ sudo pip3 install awscli --force-reinstall --upgrade

Check it works with:

(awscli) [email protected]:~/Devel/awscli$ aws --version
aws-cli/1.17.6 Python/3.6.9 Linux/4.15.0-74-generic botocore/1.14.6

Then configure with:

(awscli) [email protected]:~/Devel/awscli$ aws configure

Be the first to comment

Leave a Reply