Skip to main content

How to Use 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.

So you’ve been using AWS for awhile and finally feel comfortable clicking your way through all the services. However, you may have noticed that there is more to AWS than the default eye-catching browser console.

Maybe it’s time you checked out the AWS CLI (Command Line Interface). 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 AWS CLi and how to install it on your Windows, Linux, Mac, or Unix Operating System.

The more you use the AWS CLI, the more you’ll see how powerful it is. The Cloud Academy AWS Command Line Interface course can guide you through some of the interface’s many uses.

Here’s how you can download AWS CLI

  1. Install the AWS CLI on Windows
  2. Download the appropriate MSI installer
  3. Run the downloaded MSI installer
  4. Follow the instructions that appear

Note: The 64-bit version of the AWS CLI does not currently work with Windows Server 2008 (version 6.0.6002). Please use the 32-bit installer with this version of Windows.

Confirm the installation:
To confirm the installation, use the aws –version command at a command prompt (open the START menu and search for “cmd” if you’re not sure how to find the command prompt).

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

Once you have installed AWS CLI on your PC, you’ll need one more step to be able to connect to your AWS account.

For Windows, in my opinion, the…

aws configure

…command is the fastest way to set up your AWS CLI installation.

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

That should be it. One command you can execute from your command prompt is to list any S3 buckets you have. Try the following (provided you have permission to list S3 buckets):

aws s3 ls

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

Prerequisites 

    • Linux, OS X, or Unix
    • Python 2.6.3 or later

*A full overview on prerequisites is outlined on the AWS CLI page.

Check your Python installation:

$ python --version

If Python is not installed on your computer or you would like to install a different version of Python, follow the procedures outlined in the Python user guide documentation.

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

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

$ 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

Add your Access Key ID and Secret Access Key to ~/.aws/config using this format:

[default]
aws_access_key_id = <access key id>
aws_secret_access_key = <secret access key>
region = us-east-1

Protect the config file:

chmod 600 ~/.aws/config

Optionally, you can set an environment variable pointing to the config file. This is especially important if you want to keep it in a non-standard location. For future convenience, also add this line to your ~/.bashrc file:

export AWS_CONFIG_FILE=$HOME/.aws/config

That should be it. Try out the following from your command prompt and if you have any S3 buckets you should see them listed (again, provided you have permission to list S3 buckets):

aws s3 ls

Here is the basic AWS CLI command structure. Keep in mind 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.

Next Steps

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

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

Jeff Hyatt
Jeff Hyatt
— June 18, 2019

10 Steps for an Effective Reserved Instances Strategy

Amazon Web Services (AWS) offers three different ways to pay for EC2 Instances: On-Demand, Reserved Instances, and Spot Instances. This article will focus on effective strategies for purchasing Reserved Instances. While most of the major cloud platforms offer pre-pay and reservation dis...

Read more
  • AWS
  • EC2
Joe Nemer
Joe Nemer
— June 18, 2019

AWS Certification Practice Exam: What to Expect from Test Questions

If you’re building applications on the AWS cloud or looking to get started in cloud computing, certification is a way to build deep knowledge in key services unique to the AWS platform. AWS currently offers 11 certifications that cover major cloud roles including Solutions Architect, De...

Read more
  • AWS
  • AWS Certifications
Avatar
John Chell
— June 13, 2019

AWS Certified Solutions Architect Associate: A Study Guide

The AWS Solutions Architect - Associate Certification (or Sol Arch Associate for short) offers some clear benefits: Increases marketability to employers Provides solid credentials in a growing industry (with projected growth of as much as 70 percent in five years) Market anal...

Read more
  • AWS
  • AWS Certifications
Chris Gambino and Joe Niemiec
Chris Gambino and Joe Niemiec
— June 11, 2019

Moving Data to S3 with Apache NiFi

Moving data to the cloud is one of the cornerstones of any cloud migration. Apache NiFi is an open source tool that enables you to easily move and process data using a graphical user interface (GUI).  In this blog post, we will examine a simple way to move data to the cloud using NiFi c...

Read more
  • AWS
  • S3
Avatar
Chandan Patra
— June 11, 2019

Amazon DynamoDB: 10 Things You Should Know

Amazon DynamoDB is a managed NoSQL service with strong consistency and predictable performance that shields users from the complexities of manual setup.Whether or not you've actually used a NoSQL data store yourself, it's probably a good idea to make sure you fully understand the key ...

Read more
  • AWS
  • DynamoDB
Avatar
Andrew Larkin
— June 6, 2019

The 11 AWS Certifications: Which is Right for You and Your Team?

As companies increasingly shift workloads to the public cloud, cloud computing has moved from a nice-to-have to a core competency in the enterprise. This shift requires a new set of skills to design, deploy, and manage applications in cloud computing.As the market leader and most ma...

Read more
  • AWS
  • AWS Certifications
Sam Ghardashem
Sam Ghardashem
— May 15, 2019

Aviatrix Integration of a NextGen Firewall in AWS Transit Gateway

Learn how Aviatrix’s intelligent orchestration and control eliminates unwanted tradeoffs encountered when deploying Palo Alto Networks VM-Series Firewalls with AWS Transit Gateway.Deploying any next generation firewall in a public cloud environment is challenging, not because of the f...

Read more
  • AWS
Joe Nemer
Joe Nemer
— May 3, 2019

AWS Config Best Practices for Compliance

Use AWS Config the Right Way for Successful ComplianceIt’s well-known that AWS Config is a powerful service for monitoring all changes across your resources. As AWS Config has constantly evolved and improved over the years, it has transformed into a true powerhouse for monitoring your...

Read more
  • AWS
  • Compliance
Avatar
Francesca Vigliani
— April 30, 2019

Cloud Academy is Coming to the AWS Summits in Atlanta, London, and Chicago

Cloud Academy is a proud sponsor of the 2019 AWS Summits in Atlanta, London, and Chicago. We hope you plan to attend these free events that bring the cloud computing community together to connect, collaborate, and learn about AWS. These events are all about learning. You can learn how t...

Read more
  • AWS
  • AWS Summits
Paul Hortop
Paul Hortop
— April 2, 2019

How to Monitor Your AWS Infrastructure

The AWS cloud platform has made it easier than ever to be flexible, efficient, and cost-effective. However, monitoring your AWS infrastructure is the key to getting all of these benefits. Realizing these benefits requires that you follow AWS best practices which constantly change as AWS...

Read more
  • AWS
  • Monitoring
Joe Nemer
Joe Nemer
— April 1, 2019

AWS EC2 Instance Types Explained

Amazon Web Services’ resource offerings are constantly changing, and staying on top of their evolution can be a challenge. Elastic Cloud Compute (EC2) instances are one of their core resource offerings, and they form the backbone of most cloud deployments. EC2 instances provide you with...

Read more
  • AWS
  • EC2
Avatar
Nitheesh Poojary
— March 26, 2019

How DNS Works – the Domain Name System (Part One)

Before migrating domains to Amazon's Route53, we should first make sure we properly understand how DNS worksWhile we'll get to AWS's Route53 Domain Name System (DNS) service in the second part of this series, I thought it would be helpful to first make sure that we properly understand...

Read more
  • AWS