Chapter 6 AWS CLI

AWS Command Line Interface

Why do we need AWS CLI?

Consider you have multiple services in AWS and you want to manage them through terminal session. Then you can configure AWS CLI and can manage your AWS services from a terminal session. You can control them and automate them as per business requirement.

What is AWS CLI?

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

Now lets understand its practical through Lab. We will connect AWS CLI and will use our services like S3, EC2 etc.

Prerequisite: Chapter 1-EC2 Instance Creation.

Step 1: Login to AWS Console. Navigate to IAM service.

Step 2: Navigate to User and create user.

Click on Left side Pane – Users link. Enter UserName ,mark checkbox and provide next permission.

Step 3: Create Group: Provide Group Name and select AdministratorAccess. Click on Create Group.

A screenshot of a cell phone

Description automatically generated

Group is created.

Step 4: Click on next and user is created.

A screenshot of a social media post

Description automatically generated

Here we can find Access Key ID and Secret access Key and please download csv file.

Step 5: Create an EC2 Instance and connect to cmd.(follow chapter 1- EC2 Instance Creation).

How to login EC2 instance through command line?

At the end , we will get below EC2 connection:

[ec2-user@ip-172-11-1-111 ~]$

  1. Type command aws s3 ls to see s3 buckets.

It means , its not configured. So now lets configure aws cli.

Type command as \

Aws configure

Post this command, it will ask above details as

Access Key ID

Secret Access Key

Default region name

And default output format.

Now type command

Aws s3 ls

 It will list out all S3 buckets present in aws region.

Now lets navigate to root.

And move to directory

.aws.

Then list out through ls command.

It will list out config and credentials.

We can see credentials details through below command:

Nano credentials.

*************************************************************************************

Q) Is Roles more secure?

Ans: Roles are more secure compare to storing your access key and secret access key on individual EC2 instances. Roles are easier to manage. It can be assigned to an EC2 instance after it is created using both the console & command line. And it is universal — you can use this in any region.

  •  in the volume to Amazon S3, where it is stored in multiple Availability Zones.

Related Topics:

Chapter-2 EC2 Instance Termination

Chapter-3 EC2-Security Groups

Chapter-1 EC2 Instance Creation

Chapter-5 EC2-CloudWatch

Chapter-4 EC2 EBS

Chapter 7 AWS Boot Strap Scripts

EC2 Knowledge Check

For latest updates please join FB group cloudvikas.com (search in FaceBook) or click on link Cloudvikasgroup