Blog

/How to: Install the AWS CLI on Ubuntu

How to: Install the AWS CLI on Ubuntu

Introduction

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

For more information & available commands, please see the AWS CLI documentation.

Installation

First things first, let’s ensure our list of available packages is up to date. Run the following command:

sudo apt-get update

Next, let’s install the Python package management system:

sudo apt-get install -y python-pip

Now let’s install the AWS Command Line Interface (CLI):

sudo pip install awscli

As a final configuration step, you will need to create a plain text file within your home folder, with the following folder, and with the following name:

  • If root user: /root/.aws/config
  • If sudo user: /home/[USER NAME]/.aws/config

Reaplace [USER NAME] with your actual user name on the system.

Put the following content in the file named config from above:

[default]
aws_access_key_id = [ACCESS KEY]
aws_secret_access_key = [SECRET KEY]
region = us-west-1

Be sure to replace [ACCESS KEY] and [SECRET KEY] with your AWS access & secret keys. Also, change the region to match your preferred Amazon Web Services region.

Lastly, run the following command to lock down this file from prying eyes:

chmod 600 $HOME/.aws/config

As an option, set a variable in your bashrc file (located at $HOME/.bashrc) pointing to the above configuration file. This is only required if you decide to store the above file outside of your home folder.

Add the following line to the end of the above file, ensuring proper path to your configuration file:

export AWS_CONFIG_FILE=$HOME/.aws/config

Testing

To check that everything is installed and working properly, run the following command. You should see a JSON list of all available EC2 instances:

aws ec2 describe-regions

Conclusion

There you have it! Your system is now fully configured and ready to interact with the AWS CLI.

Stay tuned for further articles & tutorials on interacting and using the AS CLI for various features & functions!

By | 2017-04-24T11:50:24+00:00 April 4th, 2016|Amazon Web Services, Web Design & Development|