How to Use AWS CLI

One can use AWS CLI (Command Line Interface) to manage all the AWS cloud services from the terminal, which allows you to control and configure multiple AWS services.

If you’ve become familiar using AWS and feeling confident about deploying services via browser console, then there’s another way that can be achieved, that is by using AWS CLI (Command Line Interface).

If you’ve not heard about it, then this is the right time for you to check out AWS CLI (Command Line Interface). The AWS CLI is a centralized tool to manage AWS services from the terminal. There’s no need to download multiple things to configure in your system.

AWS provides you a single tool to download and configure the AWS CLI which can be used to manage AWS services using the terminal, also you can automate through scripts. Let’s show you how to install the AWS CLI on your PC and how to use it.

The more you use the AWS CLI, the more you will be familiar with it and in the process, you will understand how powerful it is.

How to download and install AWS CLI (Command Line Interface)

1. Install the AWS CLI on Windows

2. Download the MSI installer (32-bit or 64-bit)

3. Run the downloaded MSI installer

4. Follow the instructions that appear

Note: Windows server 2008 (version 6.0.6002) currently does not support 64-bit version of AWS CLI. In such a scenario, we advise you to use the 32-bit installer.

Next step is the confirm the installation, use the command “aws -version” in the command prompt. To launch the command prompt, simply type cmd in the start menu and click to launch the application.

64 Bit

The CLI installs to C:\Program Files\Amazon\AWSCLI

C:\Program Files\Amazon\AWSCLI>aws –version

aws-cli/1.7.24 Python/2.7.9 Windows/8

32 Bit

The CLI installs to C:\Program Files (x86)\Amazon\AWSCLI

C:\Program Files (x86)\Amazon\AWSCLI>aws –version

aws-cli/1.7.24 Python/2.7.9 Windows/7

After the installation of AWS CLI on your PC, you have one more step to connect to your AWS account.

Hit the command “aws configure” in the command prompt which will then trigger you with additional 4 pieces of information. Keep the Access Key ID and Secret Access Key of your account in handy, which serve as your account credentials. If you do not have them, generate one in the AWS Identity and Access Management (IAM). Next, you will be prompted to enter the region and output format, leave this blank and hit enter.

aws configure

AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE

AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Default region name [None]:

Default output format [None]:

Now you can use the command line to manage your AWS services. For example, you can run the below command to list the S3 buckets if you have them. Go ahead and try for yourself:

aws s3 ls

Install the AWS CLI on Mac, Linux, or Unix Operating System

Some of the prerequisites for installing AWS CLI are:

Linux, OS X, or Unix

Python 2.6.3 or later

Check your Python installation by entering the below command in the terminal:

$ python –version

If Python is not installed on your PC or if you would like to install latest version of Python then please follow the procedure outlined in the Python user guide documentation.

Follow the below steps from the command line to install AWS CLI:

This post offers a quick guide to installing the Python version of AWS CLI on Windows.

$ 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

Before you jump to the next step go ahead and add your Access Key ID and Secret Access Key to ~/.aws/config using the below format:

[default]

aws_access_key_id = <access key id>

aws_secret_access_key = <secret access key>

region = us-east-1

Protect the config file by changing the permission as below:

chmod 600 ~/.aws/config

Alternatively, you can set an environment variable pointing to the config file. This is important if you would want to keep it in the non-standard location. To future proof, also add the below line to your ~/.bashrc file:

export AWS_CONFIG_FILE=$HOME/.aws/config

Once that is done, try out the following from your terminal to list all the S3 buckets:

aws s3 ls

Below is the basic AWS CLI command structure. Please note that any commands you enter in the CLI will have this standard format:

aws <command> <subcommand> [options and parameters*]

*Parameters can take various types of input values including numbers, strings, lists, maps, and JSON structures.


Author Bio: Ninad Gupte is AWS Cloud Solutions Architect, with more than 20 years experience in Hosting and Managed IT Services. He actively works on Cloud Adoption, Migration, Management, Security and Optimisation projects. He is the founder of Interpole Technologies. Connect with him via Twitter, Facebook and Linkedin.

About Amit Shaw

Amit Shaw, Administrator of iTechCode.He is a 29 Year Ordinary Simple guy from West Bengal,India. He writes about Blogging, SEO, Internet Marketing, Technology, Gadgets, Programming etc. Connect with him on Facebook, Add him on LinkedIn and Follow him on Twitter.