Install and Configure AWS CLI

How to Install the AWS Command Line on Ubuntu

Visit the ansible install howto to understand how to arrive at a machine that can manage many others.
This use case is about connecting with the Amazon Web Services CLI (Command Line Interface) from any Ubuntu server. This requires the python libraries and they will have been already installed before Ansible was put on. Right now AWS CLI requires Python 2.7.

1. Install a Python Launguage Capability

To install AWS CLI we must first install the python installer called pip. Remember that Python 2.7 is already on the machine. The python-pip package will do nicely.

sudo apt-get --assume-yes install python-pip

Test your installation with the command pip --version and you should be comforted in receiving pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7).

2. Install the AWS CLI (Command Line Interface)

To install the aws command line interface we type the following command.

pip install awscli

The result if successful will show you that it is downloading the below packages. Note the S3 bucket api, the RSA encryption algorithm, the boto python library, the YAML configuration file format and other key infrastructure and provisioning assets.

    Downloading awscli-1.11.44-py2.py3-none-any.whl (1.1MB)
    Downloading s3transfer-0.1.10-py2.py3-none-any.whl (54kB)
    Downloading rsa-3.4.2-py2.py3-none-any.whl (46kB)
    Downloading botocore-1.5.7-py2.py3-none-any.whl (3.2MB)
    Downloading PyYAML-3.12.tar.gz (253kB)
    Downloading colorama-0.3.7-py2.py3-none-any.whl
    Downloading docutils-0.13.1-py2-none-any.whl (537kB)
    Downloading futures-3.0.5-py2-none-any.whl
    Downloading pyasn1-0.1.9-py2.py3-none-any.whl
    Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
    Downloading jmespath-0.9.1-py2.py3-none-any.whl
    Downloading six-1.10.0-py2.py3-none-any.whl
    ...
    ...
    Installing collected packages: futures, six, python-dateutil, docutils, jmespath, botocore, s3transfer, pyasn1, rsa, PyYAML, colorama, awscli
    Successfully installed PyYAML-3.11 awscli botocore colorama docutils futures jmespath pyasn1 python-dateutil rsa s3transfer six-1.10.0
  

pip --version

3. How to pull down the AWSCLI

We use curl to fetch the command line interface.

curl “https://s3.amazonaws.com/aws-cli/awscli-bundle.zip” -o “awscli-bundle.zip”

4. How to Install the AWS CLI (Command Line Interface)

To install the aws command line interface we type the following command.

sudo apt-get install awscli

    Just in case you cannot install awscli use these tactics.
    curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"

  

Now to check the instal we issue aws --version

The reply is expected to be

    aws-cli/1.11.44 Python/2.7.12 Linux/4.4.0-59-generic botocore/1.5.7
  

5. How to Configure the AWS Command Line Interface

Configuring the AWS command line interface involves authentication with security credentials and selection of the AWS region. Ensure that the container’s (machine’s) time is accurate or else the AWS cloud actor will refuse the request.

Go into the AWS console and click into the Users section. Opt to create a new user and select the “programmatic” option – do not give them access to the console.

The “job functions” are easier than the policies. Give the user the job functions named “SYSTEM_ADMINISTRATOR” and “DATABASE_ADMINISTRATOR” and you are good to go. Then retrieve you AWS access key and secret and use the below commands to export so that they become environment variables.

    export AWS_ACCESS_KEY_ID=AJKUGUYKIAIOJEKHLKJHGFFE
    export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXX
  

Use the “printenv” command to view the list of environment variables. Check that the values you have just set are indeed amongst the ubiquitous environment variables clan. If so you are ready to run your first AWS CLI (Command Line Interface) command.

Now to check the instal we issue aws --version

Leave a Reply

Your email address will not be published. Required fields are marked *