All about Aws Cli(command line interface)

priyanka kumari
6 min readOct 12, 2023

--

Hii folk

🚀 Excited to share day 10 of comprehensive 30 days of AWSlearning path 🎮🎉👇

Welcome to Day 10 of our comprehensive 30-day aws learning path! In today’s session, we’ll be delving into the fascinating world of cloud AWS CLI . By the end of this lesson, we’ll have a solid understanding of cloud how it’s functions

Today, we’ll take a look at a brief about AWS cli. Our goal is to focus on fundamentals then identify and learn the most commonly used services first and learn specialized services on a need-to-know basis.

What is AWS CLI?

AWS CLI is an open-source command-based application developed by AWS for easy management of your AWS cloud service. It provides different commands for managing AWS cloud services. It is compatible with the windows command line, Linux/Mac shell programs, and even remote terminals like putty.

It is one of many ways a developer can access and manage AWS services. You can also go use the AWS Management Console and AWS APIs to do the same, but why should you use AWS CLI? Let’s look at some pointers.

Understanding AWS CLI

AWS CLI is a native tool that you can use to make your life easier. You can run commands in the terminal of your operating system. For windows, you can run commands in the command prompt. For Linux and Mac, you can use any shell programs like Bash, Zsh, or Tcsh. You can even run AWS CLI commands on remote EC2 instances through putty or SSH. Just like you would set up and manage different AWS services through its console, you can perform all the functions through the CLI tool.

What is the use of AWS CLI?

AWS CLI is a very useful tool for configuring AWS cloud services, especially the ones requiring multiple steps. You can even automate repetitive tasks through CLI. Automating tasks saves developers time, and they do not need to log in to the console. Once you configure your AWS credentials, you do not need to provide your credentials again and again — unlike the console application, where you are required to provide your credentials every time you access your AWS cloud services.

Some benefits of Aws CLI

Very simple: There are no complex tasks required to start with AWS CLI. It’s very straightforward: download AWS CLI, and then install and configure it.

Saves a lot of time: For example, if you want to check out all the S3 buckets in your account, you don’t need to login to your Management Console, choose the service, and then take a look at all the buckets. Instead, you can just type in a single command and get the list.

Run powerful scripts: The biggest reason to use AWS CLI is that you can run scripts that can automate the cloud infrastructure partially or fully.

Access all of AWS IaaS: It started with just EC2 access, and now you can manage every IaaS AWS resource from the CLI.

Types of AWS CLI

Before starting to install, let’s discuss the different AWS CLI versions. There are two versions of AWS CLI namely:

AWS CLI version 1:

This is the first release of the AWS CLI tool, and it’s still supported by AWS. A lot of new features are introduced in AWS CLI version 2, but those features cannot be backported to version 1. To use those features, you must install AWS CLI version 2.

AWS CLI version 2:

This is the current AWS CLI version. You can only install version 2 as a bundled installer. Let’s take a look at all the new features of CLI version 2.

  • Import AWS credentials from CSV files.
  • Autocomplete server-side resource names
  • Auto-prompt of AWS CLI parameters to help users. Using the –cli-auto-prompt option, you can prompt for the next entry. For example, check out this image:

Installing AWS CLI

Prerequisites for the installation on Windows:

  • AWS CLI version 2 is supported on Windows XP or later.
  • AWS CLI version 2 supports only 64-bit versions of Windows.

To install AWS CLI for Windows, you will have to download the AWS CLI MSI installer. Download it from the below link:

AWS CLI Install Download link — AWS CLI MSI Installer

Download the AWS Command Line Interface for Windows and once it is downloaded, install it like you would install any software with the wizard. Let me give a few screenshots to make it clear.

How to generate AWS CLI Credentials

The following items are required to set up and manage AWS services with AWS CLI:

1. An AWS account

2. IAM user credentials

3. IAM access key pair generated by the IAM user

When you run the AWS CLI commands, the AWS CLI accesses these AWS credentials. Creating AWS credentials is therefore mandatory for using AWS CLI.

Note: Never use a root account for managing and creating services. Best practice is to always use an IAM account (IAM user).

Steps to generate AWS credentials

  1. Log in in to the AWS Management Console and search for IAM.

2. In the navigation pane, select Users link.

3. In the Users section, Select the name of the user whose access keys you want to create.

4. Click on the Security credentials tab.

5. In the Access keys section, choose Create access key.

6. To view the new access key pair, select Show

How to configure AWS Credentials on Windows

Run the command “aws configure” in cmd to start setting up the configuration. Once we enter this command, AWS CLI prompts us with four pieces of information:

1. Access Key ID: (enter your id)

2. Secret Access Key: (enter your key)

3. AWS Region: (enter the desired location)

4. Output Format: (enter desired output)

Commonly Used Commands in AWS CLI

Some of the most common CLI commands are the following:

Configuration Commands

For Create profiles:

Aws configure –profile profile name

Output format:

Aws configure output format

To specify your AWS region:

Aws configure region (region-name)

for Amazon EC2 Commands

Launch an Amazon EC2 instance (must update the AMI ID):

Aws ec2 run-instances –instance-type t2. micro –image-id ami-0f5411afa59916e0e –region us-east-1

THANKS FOR READING

I hope found this useful?

✅Reshare this with others so that it helps more people

✅Tag your colleagues and friends who you think will need this

--

--

priyanka kumari
priyanka kumari

Written by priyanka kumari

Cloud || Devops enthusiast|| Learning & helping

No responses yet