≡ Menu

OS X install Amazon AWS command-line interface (CLI) tool

How do I setup and install the official Amazon AWS Command Line Interface (cli) on an Apple Mac OS X system?

The official or universal command line interface for Amazon Web Services recommended tool for the AWS. There are various ways to install the AWS CLI.

Prerequisites

You must have Python installed on the system. The aws cli package works on Python versions:

  • 2.6.5+
  • 2.7.x+
  • 3.3.x+
  • 3.4.x+

Finding out your Python version

Open the Terminal and type the following command:
$ python --version
$ sw_vers

Sample outputs:

Fig.01: OS X Find Out Python Version

Fig.01: OS X Find Out Python Version

Method #1: Install the aws-cli using brew

Type the following command:
$ brew install awscli
Add the following to ~/.bashrc to enable bash completion for aws command:

 echo 'complete -C aws_completer aws' >> ~/.bashrc

Add the following to ~/.zshrc to enable zsh completion:

 echo 'source /usr/local/share/zsh/site-functions/_aws' >> ~/.zshrc

Method #2: Install the aws-cli using the official Amazon installer

Type the following command:
$ cd /tmp
$ curl -o awscli.zip https://s3.amazonaws.com/aws-cli/awscli-bundle.zip

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 6501k  100 6501k    0     0   399k      0  0:00:16  0:00:16 --:--:--  542k

Unzip the awscli.zip file:
$ unzip awscli.zip
Sample outputs:

Archive:  awscli.zip
  inflating: awscli-bundle/install   
  inflating: awscli-bundle/packages/jmespath-0.9.0.tar.gz  
  inflating: awscli-bundle/packages/rsa-3.3.tar.gz  
  inflating: awscli-bundle/packages/simplejson-3.3.0.tar.gz  
  inflating: awscli-bundle/packages/python-dateutil-2.4.2.tar.gz  
  inflating: awscli-bundle/packages/ordereddict-1.1.tar.gz  
  inflating: awscli-bundle/packages/colorama-0.3.3.tar.gz  
  inflating: awscli-bundle/packages/docutils-0.12.tar.gz  
  inflating: awscli-bundle/packages/botocore-1.3.23.tar.gz  
  inflating: awscli-bundle/packages/argparse-1.2.1.tar.gz  
  inflating: awscli-bundle/packages/awscli-1.10.1.tar.gz  
  inflating: awscli-bundle/packages/pyasn1-0.1.9.tar.gz  
  inflating: awscli-bundle/packages/virtualenv-13.0.3.tar.gz  
  inflating: awscli-bundle/packages/six-1.10.0.tar.gz

Install it:
$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Sample outputs:

Running cmd: /usr/local/opt/python/bin/python2.7 virtualenv.py --python /usr/local/opt/python/bin/python2.7 /usr/local/aws
Running cmd: /usr/local/aws/bin/pip install --no-index --find-links file:///private/tmp/awscli-bundle/packages awscli-1.10.1.tar.gz
Symlink already exists: /usr/local/bin/aws
Removing symlink.
You can now run: /usr/local/bin/aws --version

How do I use the aws-cli?

You must have an AWS account. Visit http://aws.amazon.com/.

Create the AWS access key ID and secret access key

  1. Visit the IAM console
  2. Select your IAM user name.
  3. Select the Security Credentials tab and then Create Access Key.

Sample outputs:

Fig.02:  Get your access key ID and secret access key

Fig.02: Get your access key ID and secret access key


To see your access key, choose Show User Security Credentials.
Fig.03: Choose Download Credentials, and store the keys in a secure location

Fig.03: Choose Download Credentials, and store the keys in a secure location

Configure the aws-cli

Type the following command and when prompted enter the AWS Access Key ID and AWS Secret Access Key:
$ aws configure
Sample outputs:

Fig.04: aws configure in action

Fig.04: aws configure in action


Now you can use the aws command to control your cloud hosted by the Amazon AWS. The syntax is:
$ aws command
$ aws help
$ aws ec2 help
## examples ##
$ aws ec2 describe-instances --output table
$ aws --region=us-east-1 acm list-certificates
$ aws --region=us-east-1 acm list-certificates --certificate-statuses ISSUED

References

See Using the AWS Command Line Interface for more information.

Sysadmin because even developers need heroes!!!

Share this tutorial on:
{ 2 comments… add one }
  • Pradeep Kumar February 4, 2016, 2:44 am

    Very nice. It really helped me a lot.

  • Asad May 26, 2016, 12:42 pm

    Thanks

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: ,