AWS CLI: A Beginners Guide

(Update) We recommend reading How to Use AWS CLI blog post if you’re interested in learning more about AWS CLI. Also, the Cloud Academy’s AWS CLI Course is your go-to course if you want to start studying this topic.


The AWS CLI is for managing your AWS services from a terminal session on your own PC, allowing you to control and script multiple AWS services.

So you’ve got yourself an AWS account and, after a few months, you’re feeling pretty comfortable clicking your way through all the services. But you definitely get the feeling that there may be a little more to this AWS thing than their 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 PC. 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 article, I will show you how to install the AWS CLI on your Windows PC or on a Linux, Mac, or Unix Operating System.

The more you use the AWS CLI, the more you’ll see how powerful it is. Cloud Academy has a terrific course on the AWS CLI that can guide you through some of the interface’s more sophisticated uses. In any case, here’s how it works:

AWS CLI setup: Download and installation on Windows

  1. Download the appropriate MSI installer.

    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.

  2. Run the downloaded MSI installer.
  3. Follow the instructions that appear.

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

OK. That was pretty easy. However, we’ve only installed AWS CLI on your PC. To be able to connect to your AWS account, you’ll need one more step.
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 AWS Access Key ID and AWS Secret Access Key are your account credentials. Those you will definitely need to provide. You can probably leave the other two – region and output format – 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. Try out the following command from your cmd prompt and, if you have any s3 buckets, you should see them listed

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

Check your Python installation:

$ python --version

If your computer doesn’t already have Python installed, or you would like to install a different version of Python, follow the procedure in Install Python.

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:

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, such as numbers, strings, lists, maps, and JSON structures.

How to use AWS CLI

So, hopefully, you now have the AWS CLI installed on your PC. What next? Maybe the first thing would be to get a CLI-driven feel for what you have on your S3 account.

Here are some suggestions:

List all your users and display the output in a table:

aws iam list-users --output table

List all your EC2 tags:

aws ec2 describe-tags --output table

Play around with outputs, help, or whatever:

aws ec2 describe-spot-price-history help
aws ec2 describe-instances
Avatar

Written by

Michael Sheehy

I have been UNIX/Linux System Administrator for the past 15 years and am slowly moving those skills into the AWS Cloud arena. I am passionate about AWS and Cloud Technologies and the exciting future that it promises to bring.


Related Posts

Amanda Cross
Amanda Cross
— January 7, 2021

New Content: AWS Terraform, Java Programming Lab Challenges, Azure DP-900 & DP-300 Certification Exam Prep, Plus Plenty More Amazon, Google, Microsoft, and Big Data Courses

This month our Content Team continues building the catalog of courses for everyone learning about AWS, GCP, and Microsoft Azure. In addition, this month’s updates include several Java programming lab challenges and a couple of courses on big data. In total, we released five new learning...

Read more
  • AWS
  • Azure
  • DevOps
  • Google Cloud Platform
  • Machine Learning
  • programming
Avatar
Stuart Scott
— December 17, 2020

Where Should You Be Focusing Your AWS Security Efforts?

Another day, another re:Invent session! This time I listened to Stephen Schmidt’s session, “AWS Security: Where we've been, where we're going.” Amongst covering the highlights of AWS security during 2020, a number of newly added AWS features/services were discussed, including: AWS Audit...

Read more
  • AWS
  • AWS re:Invent
  • cloud security
Joe Nemer
Joe Nemer
— December 4, 2020

AWS re:Invent: 2020 Keynote Top Highlights and More

We’ve gotten through the first five days of the special all-virtual 2020 edition of AWS re:Invent. It’s always a really exciting time for practitioners in the field to see what features and services AWS has cooked up for the year ahead.  This year’s conference is a marathon and not a...

Read more
  • AWS
  • AWS Glue Elastic Views
  • AWS re:Invent
Bryony Harrower
Bryony Harrower
— November 6, 2020

WARNING: Great Cloud Content Ahead

At Cloud Academy, content is at the heart of what we do. We work with the world’s leading cloud and operations teams to develop video courses and learning paths that accelerate teams and drive digital transformation. First and foremost, we listen to our customers’ needs and we stay ahea...

Read more
  • AWS
  • Azure
  • content roadmap
  • GCP
Joe Nemer
Joe Nemer
— October 25, 2020

Excelling in AWS, Azure, and Beyond – How Danut Prisacaru Prepares for the Future

Meet Danut Prisacaru. Danut has been a Software Architect for the past 10 years and has been involved in Software Engineering for 30 years. He’s passionate about software and learning, and jokes that coding is basically the only thing he can do well (!). We think his enthusiasm shines t...

Read more
  • AWS
  • careers
  • champions
  • upskilling
Joe Nemer
Joe Nemer
— October 14, 2020

New Content: AWS Data Analytics – Specialty Certification, Azure AI-900 Certification, Plus New Learning Paths, Courses, Labs, and More

This month our Content Team released two big certification Learning Paths: the AWS Certified Data Analytics - Speciality, and the Azure AI Fundamentals AI-900. In total, we released four new Learning Paths, 16 courses, 24 assessments, and 11 labs.  New content on Cloud Academy At any ...

Read more
  • AWS
  • Azure
  • DevOps
  • Google Cloud Platform
  • Machine Learning
  • programming
Joe Nemer
Joe Nemer
— September 15, 2020

New Content: Azure DP-100 Certification, Alibaba Cloud Certified Associate Prep, 13 Security Labs, and Much More

This past month our Content Team served up a heaping spoonful of new and updated content. Not only did our experts release the brand new Azure DP-100 Certification Learning Path, but they also created 18 new hands-on labs — and so much more! New content on Cloud Academy At any time, y...

Read more
  • AWS
  • Azure
  • DevOps
  • Google Cloud Platform
  • Machine Learning
  • programming
Joe Nemer
Joe Nemer
— August 28, 2020

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 12 certifications that cover major cloud roles including Solutions Architect, De...

Read more
  • AWS
  • AWS Certifications
Patrick Navarro
Patrick Navarro
— August 25, 2020

Overcoming Unprecedented Business Challenges with AWS

From auto-scaling applications with high availability to video conferencing that’s used by everyone, every day —  cloud technology has never been more popular or in-demand. But what does this mean for experienced cloud professionals and the challenges they face as they carve out a new p...

Read more
  • AWS
  • Cloud Adoption
  • digital transformation
Avatar
Andrew Larkin
— August 18, 2020

Constant Content: Cloud Academy’s Q3 2020 Roadmap

Hello —  Andy Larkin here, VP of Content at Cloud Academy. I am pleased to release our roadmap for the next three months of 2020 — August through October. Let me walk you through the content we have planned for you and how this content can help you gain skills, get certified, and...

Read more
  • alibaba
  • AWS
  • Azure
  • content roadmap
  • Content updates
  • DevOps
  • GCP
  • Google Cloud
  • New content
Alisha Reyes
Alisha Reyes
— August 5, 2020

New Content: Alibaba, Azure AZ-303 and AZ-304, Site Reliability Engineering (SRE) Foundation, Python 3 Programming, 16 Hands-on Labs, and Much More

This month our Content Team did an amazing job at publishing and updating a ton of new content. Not only did our experts release the brand new AZ-303 and AZ-304 Certification Learning Paths, but they also created 16 new hands-on labs — and so much more! New content on Cloud Academy At...

Read more
  • AWS
  • Azure
  • DevOps
  • Google Cloud Platform
  • Machine Learning
  • programming
Alisha Reyes
Alisha Reyes
— July 16, 2020

Blog Digest: Which Certifications Should I Get?, The 12 Microsoft Azure Certifications, 6 Ways to Prevent a Data Breach, and More

This month, we were excited to announce that Cloud Academy was recognized in the G2 Summer 2020 reports! These reports highlight the top-rated solutions in the industry, as chosen by the source that matters most: customers. We're grateful to have been nominated as a High Performer in se...

Read more
  • AWS
  • Azure
  • blog digest
  • Certifications
  • Cloud Academy
  • OWASP
  • OWASP Top 10
  • Security
  • VPCs