Amazon Web Services Command Line Interface is designed to help you manage all your AWS services through a terminal session on your clients. This enables you to configure several AWS services as well as control and implement a higher level of automation.

 

Amazon Web Services (AWS) offers computing power, a storage database, content delivery and other functionalities that help businesses to upscale and grow. In other words, AWS lets you do several things like running web servers and application servers on the cloud that allow businesses to host dynamic platforms and websites.

 

If you have used AWS for a while and are comfortable with the many clicks that get you through all your existing services, you’ll know that AWS is more than just the default browser console. The AWS CLI helps you unleash greater potential when it comes to managing your AWS environment. It is a unified tool, which makes it really easy to download and configure. You can also control several AWS offerings from the command line and use scripts to automate these offerings.

 

The more you use the AWS CLI, the more you will see its capabilities. This post talks about everything you should know about downloading and installing AWS CLI on 

  • Windows
  • Linux/ MacOS/ Unix
  • Docker

You can also learn how to configure the AWS CLI and leverage its built-in help tools. 

 

How to Download and Install the AWS CLI

If you are new to the AWS CLI or don’t use it on a particular system just yet, start by downloading the program. The configuration and installation method will differ on the basis of your operating system.

 

The AWS CLI For Linux, MacOS and Unix

Prerequisites for downloading:

You need to have Python 2 v2.6.5 or higher. Alternatively, you must have Python 3 v3.3 or higher installed on your system. To check which version you are running, run the following command:

“ python --version “

 

The installation process:

 

It is highly recommended that you use the installer bundle that AWS provides. This bundled installer comprises everything you will need to complete the installation.

 

Step 1:

Run this command to start the installation process:

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

 

Step 2:

Unzip the package you just downloaded using the following command:

unzip awscli-bundle.zip

 

Step 3:

Once you unzip the package, you simply have to run the installation. You can do so using this command:

sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws 

 

The -b option is used to enable all the users of your system to run the AWS CLI from any directory. This means you won’t have to detail out the install directory in your $PATH variable. 

 

AWS CLI For Windows

Prerequisites for downloading:

Your system must have Windows XP or any version later than that.

 

The installation process:

You can choose from 3 MSI installers for your Windows system.

  • 64-bit versiom
  • 32-bit version
  • CLI Setup file. This file automatically detects the system that you choose to run the CLI on and installs the most suitable one out of the 64-bit and 32-bit versions.

Step 1: 

Select the version option needed for downloading the MSI.

 

Step 2:

Run the MSI installer that you downloaded or the Setup file for CLI

 

Step 3:

Follow the instructions that pop up. After it is complete, your program files get stored on your system as demonstrated below:

 

64-bit version

C:\Program Files\Amazon\AWSCLI

 

32-bit version

C:\Program Files(x86)\Amazon\AWSCLI

 

To confirm and complete the installation, use this command in the prompt

aws --version

 

AWS CLI For Docker

Prerequisites for downloading:

For this, you need to have Docker, a set of Platform as a Service products installed on your system. Check which version of Docker you have installed on your system, run this command and ensure you get an output.

 

$ docker --version

 

Running the AWS CLI version 2 Docker image

The Docker image of AWS CLI version 2 is hosted on DockerHub. The repository where you can find it is amazon/aws-cli.

 

When you use the ‘docker run’ command for the first time, it downloads the latest Docker image to your system. Any time after that when you use the ‘docker run’ command, it is run from the local copy you made. 

 

To run the version 2 Docker image, use the following command

 

$ docker run --rm -it amazon/aws-cli command

 

How to Configure the AWS CLI:

Once the AWS CLI is installed on your system, you must configure it so that you can connect it to your AWS service account. For configuration, run this command:

 

aws configure

This command will then open up a dialog box and ask you for 4 data points. The first two are mandatory, your AWS access key ID and your AWS secret access key. These are account credentials for anyone holding an AWS account. If you don’t have these credentials, you can generate them in AWS IAM (Identity and Access Management). The other two pieces of information asked for by the command prompt are your region and the output format. You can leave them at default settings. This is what your command prompt should look like:

 

aws configure 

AWS Access Key ID [None]: AKIAIOSF13JSSLKVSON

AWS Secret Access Key [None]: lkfdjd@I$OJFDDKVdfua?>>Yejfna22/skdmSSKV 

Default region name [None]: india-delhi 

Default output format [None]: json

 

The default region information block tells you where your requests will be sent. There are several different regions available for you to choose from. 

 

The output format information block tells you which formatting will be used to show you results. The possible values in this block are

  • json
  • text
  • table

Your AWS secret access and access key ID verify your AWS account. This allows you to execute specific functions and tasks that are defined by the level of your permissions.

 

Your AWS access key ID comprises 20 random alphanumeric characters as shown above. On the other hand, the AWS secret access key comprises 40 random characters made up of uppercase and lowercase letters and alphanumeric and non-alphanumeric characters.

 

Access keys can be created for all IAM users who need verification and authorisation coming from a programmatic perspective, for example, while using the AWS CLI.

 

AWS-shell

AWS-Shell is a command-line shell program that allows access to both convenience and functionality features that can help both new and experienced users to navigate the AWS CLI. The most important functions of this command line are:

  • Fuzzy auto-completion that is useful for
  • Commands (for example ec2, describe-instances, sqs, create-queue)
  • Options (for example --instance-ids, --queue-url)
  • Resource identifiers (for example, Amazon ec2 instance IDs, Amazon SQS queue URLs)
  • Dynamic in-line documentation
  • Documentation is displayed for respective commands and options as you type
  • OS shell command executions
  • You can use OS commands like cat, ls and generate inputs and outputs without leaving any shell
  • Exporting commands after execution to a text editor

It is important to know that you cannot retrieve your access key IDs if you lose them. AWS does not keep copies of these access key IDs due to security reasons to keep your information safe. By keeping your access keys associated with the AWS CLI, AWS ensures that all your API requests are authenticated and authorised with your digital signature.

 
Armin Vans
Michael Warne is a tech blogger and IT Certification Trainer at Koenig Solutions. She has an experience of 5 years in the industry, and has worked for top-notch IT companies. She is an IT career consultant for students who pursue various types of IT certifications.

COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here
You have entered an incorrect email address!
Please enter your email address here

Loading...

Submitted Successfully...