Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

🎁 Get 20% Off - Christmas Big Sale on All Practice Exams, Video Courses, and eBooks!

Working With AWS CLI (AWS Command Line Interface)

Home » AWS » Working With AWS CLI (AWS Command Line Interface)

Working With AWS CLI (AWS Command Line Interface)

Last updated on April 27, 2023

What is AWS CLI?

AWS Command Line Interface (CLI) is a tool used to manage and interact with AWS Services using the command line. Users more comfortable in the command line can leverage the AWS CLI as it offers the exact scope of functionality as the AWS Console. 

AWS CLI requires minimal configuration before you can use it. Installed it on your local machine running on Linux, Windows, and macOS.

 

What is the Difference Between AWS CLI and AWS CloudShell?

Likewise, AWS CloudShell is another tool you can use to manage AWS resources using the command line interface. But unlike AWS CLI, AWS CloudShell can run directly from the browser. Here are the notable differences between AWS CLI and AWS CloudShell.

AWS CLI

AWS CloudShell

Requires installation

No installation required

Runs on local machines/EC2 instance

Runs directly on the browser

Requires Access Keys/Roles

Pre-authenticated. Use the same credentials used in signing in on AWS Console.

 

How to Install AWS CLI

As mentioned previously, AWS CLI supports Linux, Windows, and macOS. For this example, we will install the AWS CLI on a local machine running on the Windows operating system.

 

You can download the AWS CLI installer from here or run the following command from your CMD.

Working with AWS Command Line Interface (CLI)

Working with AWS CLI (AWS Command Line Interface CLI)

 

The installation wizard will pop up. Follow the onscreen procedure for proper installation.

Tutorials dojo strip

Working with AWS CLI (AWS Command Line Interface CLI)

 

Once installation is done, check the version to verify using your CMD.

Working with AWS Command Line Interface (CLI)

Working with AWS Command Line Interface (CLI)

 

Set up the Access Keys using the following command. You will be prompted to provide AWS Access Key ID and Secret Access Key. Your CLI will use these to authenticate for you to interact with AWS Services. Additionally, you can also set the default region and output format.

Working with AWS Command Line Interface (CLI)

Working with AWS CLI (AWS Command Line Interface CLI)

Optionally, you can use the –profile option to save a configuration for a specific profile or account. AWS CLI will use the default profile if you don’t use this option.

Working with AWS CLI (AWS Command Line Interface)

On a Windows machine, you can view the saved profile from the directory below.

Working with AWS Command Line Interface (CLI)

Working with AWS Command Line Interface (CLI)

 

 

How AWS CLI Interacts with AWS Services

Here’s an example of how to launch an EC2 instance using AWS CLI.

Generate the keypair that the instance will use. This key pair will be downloaded on your local machine the same as when you create a new key pair from the AWS Console.

Working with AWS Command Line Interface (CLI)

Working with AWS Command Line Interface (CLI)

Working with AWS Command Line Interface (CLI)

 

Optional: Run the command below to verify your key pair

 

Working with AWS Command Line Interface (CLI)

 

 

Working with AWS Command Line Interface (CLI)

 

Launch an EC2 instance using the command below.

 

Working with AWS Command Line Interface (CLI)

 

In this example, a t2.micro EC2 instance is launched. You may see an output similar below.

 

Working with AWS Command Line Interface (CLI)
 
 
 
Get the instance ID of the newly created EC2.
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 
 
 
 
 
Optional: Add tags in your instance. Use the instance ID to identify your AWS resource.
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 
 
From the AWS Console, you can see the instance you have created. 
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 
To stop an instance, use the command below. Use the instance ID as an identifier.
 
 
Working with AWS Command Line Interface (CLI)
 
 
You should see an output similar to this.
 
 
Working with AWS CLI (AWS Command Line Interface CLI)
 
 
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 
To stop an instance, use the command below. Use the instance ID as an identifier.
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 
To terminate an instance, use the command below. Use the instance ID as an identifier.
 
Working with AWS Command Line Interface (CLI)
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 
Working with AWS Command Line Interface (CLI)
 
 
 

Get 20% Off – Christmas Big Sale on All Practice Exams, Video Courses, and eBooks!

Tutorials Dojo portal

Learn AWS with our PlayCloud Hands-On Labs

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

FREE AWS, Azure, GCP Practice Test Samplers

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

Follow Us On Linkedin

Recent Posts

Written by: Lervin John Obando

Lervin is a Cloud Technology enthusiast and an AWS Community Builder whose expertise expands from Systems Administration, Database to Cloud Infrastructure. He is a Multi-Cloud Certified professional holding multiple certifications from AWS, Google, and Oracle. When he is not in front of his computer, you can find him spending time with his wife and dog.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?