How to Use & Install the AWS CLI

What is the AWS CLI? |

The AWS Command Line Interface (CLI) is for managing your AWS services from a terminal session on your own client, allowing you to control and configure multiple AWS services and implement a level of automation.

If you’ve been using AWS for some time and feel comfortable clicking your way through all the services, you may have noticed that there’s more to AWS than the default eye-catching browser console. Using the AWS CLI can help you to unlock further potential when managing your AWS environment. The AWS CLI is a unified tool to manage your AWS services from a terminal session on your own client. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

In this blog, I will show you how to use the AWS CLI and how to install it on your Windows, Linux, Mac, or Unix Operating System. To see the process to configure the AWS CLI in action, check out our beginner Introduction to the AWS CLI Hands-on Lab. During this Lab, you’ll learn how to configure the AWS CLI, leverage the built-in help tool, and set up an S3 website using the AWS CLI. The more you use the AWS CLI, the more you’ll see how powerful it is.

Cloud Academy AWS CLI Lab AWI CLI Lab

Downloading and installing the AWS CLI

First, you need to download the AWS CLI. Depending on your operating system, it will require a different method.

Linux / macOS / Unix

Prerequisites:

You must ensure that you have at least Python 2 version 2.6.5+ or Python 3 version 3.3+ installed. To verify your current version, run the command:

python --version

Installation:

The recommendation for installing the AWS CLI is to use the bundled installer provided by AWS. The bundled installer includes all dependencies required for the installation.

1. To begin the installation run the following command:

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

2. Next, you must unzip the downloaded package from step 1:

unzip awscli-bundle.zip

3. Once the package in unzipped, you can run the installation:

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

Using the -b option allows all users to use the AWS CLI from any directory, meaning you will not need to specify the install directory in the user’s $PATH variable. 

Windows

Prerequisites:

You must be running Microsoft Windows XP or later.

Installation:

There are three MSI installers to choose from:

1. Select the option required to download the MSI

2. Run the downloaded MSI installer or the CLI setup file, as required

3. Follow the instructions that appear

Once installed, the program files will be stored as shown:

64-bit version

C:\Program Files\Amazon\AWSCLI 

32-bit version

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

To confirm the installation, use the aws –version command at a command prompt. 

Simple configuration of the AWS CLI

Once you have installed the AWS CLI, you now need to configure the application to be able to connect to your AWS account.  To do so, enter the following from your command prompt:

aws configure

Through aws configure, the AWS CLI will prompt you for four pieces of information. The first two are required. These are your AWS access key ID and AWS secret access key, which serve as your account credentials. You can generate new credentials within AWS Identity and Access Management (IAM) if you do not already have them. The other information you will need is region and output format, which you can leave as default for the time being.

aws configure 
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE 
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY 
Default region name [None]: us-west-2 
Default output format [None]: json

The default region name simply defines the Region where you requests will be sent to. For all available regions, please see the following: Regions and Endpoints

The default output format specifies how the results are formatted. Values that can be used here include: 

  • json 
  • text
  • table

The AWS access key ID and AWS secret access key are used to authenticate your AWS account. This authorizes you to carry out specific tasks and functions as defined by your permissions level.  

The AWS access key ID is made up of 20 random uppercase alphanumeric characters, such as the one displayed on screen.

The AWS secret access key is made up of 40 random upper and lowercase alphanumeric and non-alphanumeric characters as displayed.

These access keys can be created for any IAM user who requires authentication from a programmatic perspective, such as when using the AWS CLI.


IMPORTANT: When the access keys are created, you are prompted to download and save the details. The secret access key ID will only be displayed once, and if you lose it, then you’ll have to delete the associated access key ID and recreate new keys for the user.


It’s worth noting that it’s not possible to retrieve lost secret access key IDs as AWS does not retain copies of these for security reasons in case they were compromised. By associating the access keys with the AWS CLI, it ensures that all API requests made to AWS are signed with a digital signature.

You can use the IAM service for creating new access keys for your users. To dive deeper into this service and other authentication and access control mechanisms, go to AWS: Overview of AWS Identity & Access Management (IAM) and Understanding of AWS Authentication, Authorization & Accounting. 

AWS IAM Course

Next steps

With the AWS CLI now installed and configured on your client, you can take the next steps to configuring, managing, and scripting AWS services.

For more commands relating to the AWS CLI, take a look at the official AWS CLI documentation.

Avatar

Written by

Stuart Scott

Stuart is the AWS content lead at Cloud Academy where he has created over 40 courses reaching tens of thousands of students. His content focuses heavily on cloud security and compliance, specifically on how to implement and configure AWS services to protect, monitor and secure customer data and their AWS environment.

Related Posts

Avatar
Michael Sheehy
— August 19, 2019

What Exactly Is a Cloud Architect and How Do You Become One?

One of the buzzwords surrounding the cloud that I'm sure you've heard is "Cloud Architect." In this article, I will outline my understanding of what a cloud architect does and I'll analyze the skills and certifications necessary to become one. I will also list some of the types of jobs ...

Read more
  • AWS
  • Cloud Computing
Avatar
Nitheesh Poojary
— August 16, 2019

Boto: Using Python to Automate AWS Services

Boto allows you to write scripts to automate things like starting AWS EC2 instances Boto is a Python package that provides programmatic connectivity to Amazon Web Services (AWS). AWS offers a range of services for dynamically scaling servers including the core compute service, Elastic...

Read more
  • Automated AWS Services
  • AWS
  • Boto
  • Python
Avatar
Andrew Larkin
— August 13, 2019

Content Roadmap: AZ-500, ITIL 4, MS-100, Google Cloud Associate Engineer, and More

Last month, Cloud Academy joined forces with QA, the UK’s largest B2B skills provider, and it put us in an excellent position to solve a massive skills gap problem. As a result of this collaboration, you will see our training library grow with additions from QA’s massive catalog of 500+...

Read more
  • AWS
  • Azure
  • content roadmap
  • Google Cloud Platform
Avatar
Adam Hawkins
— August 9, 2019

DevSecOps: How to Secure DevOps Environments

Security has been a friction point when discussing DevOps. This stems from the assumption that DevOps teams move too fast to handle security concerns. This makes sense if Information Security (InfoSec) is separate from the DevOps value stream, or if development velocity exceeds the band...

Read more
  • AWS
  • cloud security
  • DevOps
  • DevSecOps
  • Security
Avatar
Stefano Giacone
— August 8, 2019

Test Your Cloud Knowledge on AWS, Azure, or Google Cloud Platform

Cloud skills are in demand | In today's digital era, employers are constantly seeking skilled professionals with working knowledge of AWS, Azure, and Google Cloud Platform. According to the 2019 Trends in Cloud Transformation report by 451 Research: Business and IT transformations re...

Read more
  • AWS
  • Cloud skills
  • Google Cloud
  • Microsoft Azure
Avatar
Andrew Larkin
— August 7, 2019

Disadvantages of Cloud Computing

If you want to deliver digital services of any kind, you’ll need to estimate all types of resources, not the least of which are CPU, memory, storage, and network connectivity. Which resources you choose for your delivery —  cloud-based or local — is up to you. But you’ll definitely want...

Read more
  • AWS
  • Azure
  • Cloud Computing
  • Google Cloud Platform
Joe Nemer
Joe Nemer
— August 6, 2019

Google Cloud vs AWS: A Comparison (or can they be compared?)

The "Google Cloud vs AWS" argument used to be a common discussion among our members, but is this still really a thing? You may already know that there are three major players in the public cloud platforms arena: Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP)...

Read more
  • AWS
  • Google Cloud Platform
  • Kubernetes
Avatar
Stuart Scott
— July 29, 2019

Deployment Orchestration with AWS Elastic Beanstalk

If you're responsible for the development and deployment of web applications within your AWS environment for your organization, then it's likely you've heard of AWS Elastic Beanstalk. If you are new to this service, or simply need to know a bit more about the service and the benefits th...

Read more
  • AWS
  • elastic beanstalk
Alisha Reyes
Alisha Reyes
— July 22, 2019

Cloud Academy’s Blog Digest: July 2019

July has been a very exciting month for us at Cloud Academy. On July 10, we officially joined forces with QA, the UK’s largest B2B skills provider (read the announcement). Over the coming weeks, you will see additions from QA’s massive catalog of 500+ certification courses and 1500+ ins...

Read more
  • AWS
  • Azure
  • Cloud Academy
  • Cybersecurity
  • DevOps
  • Kubernetes
Avatar
Stuart Scott
— July 18, 2019

AWS Fundamentals: Understanding Compute, Storage, Database, Networking & Security

If you are just starting out on your journey toward mastering AWS cloud computing, then your first stop should be to understand the AWS fundamentals. This will enable you to get a solid foundation to then expand your knowledge across the entire AWS service catalog.   It can be both d...

Read more
  • AWS
  • Compute
  • Database
  • fundamentals
  • networking
  • Security
  • Storage
Avatar
Adam Hawkins
— July 17, 2019

How to Become a DevOps Engineer

The DevOps Handbook introduces DevOps as a framework for improving the process for converting a business hypothesis into a technology-enabled service that delivers value to the customer. This process is called the value stream. Accelerate finds that applying DevOps principles of flow, f...

Read more
  • AWS
  • AWS Certifications
  • DevOps
  • DevOps Foundation Certification
  • Engineer
  • Kubernetes
Avatar
Vineet Badola
— July 15, 2019

AWS AMI Virtualization Types: HVM vs PV (Paravirtual VS Hardware VM)

Amazon Machine Images (AWS AMI) offers two types of virtualization: Paravirtual (PV) and Hardware Virtual Machine (HVM). Each solution offers its own advantages. When we’re using AWS, it’s easy for someone — almost without thinking —  to choose which AMI flavor seems best when spinning...

Read more
  • AWS
  • Hardware Virtual Machine
  • Paravirtual
  • Virtualization