Quantcast
Channel: Cloud Training Program
Viewing all articles
Browse latest Browse all 1892

What is AWS Command Line Interface (CLI) | How to Install and Configure

$
0
0

Cloud computing is getting popular among industries around the globe. Now, most enterprises are moving towards cloud computing and expanding their infrastructure footprints in the Cloud. Amazon Web Services (AWS) is the market leader and top innovator in this field. One of the AWS tools known as AWS CLI (Command-line interface). It is used to manage AWS services through commands. In this post, we will discuss what AWS Command-line interface is and how to install & configure it.

AWS supports two ways of infrastructure configurations for its Services.

  1.  Using AWS web Console
  2.  AWS Command-line interface (CLI)

In this blog, we will be focusing on AWS Command-line interface and covering topics like :

Overview of AWS Command-line interface 

AWS Command Line Interface (CLI) is a unified configuration to administer AWS public cloud services. With only one tool, we can download, configure and monitor multiple AWS services using commands and automate them via scripts. Firstly we will set up CLI on any operating system like Windows, Linux, macOS, or Docker containers then it can access all the functionality provided on the AWS portal. Moreover, you can automate the managing and controlling the process by writing the script in the programming language you are familiar with.That script allows deploying multiple resources without having to go through the entire configuration wizard each time. In simple, with the help of AWS CLI, you can manage and control all services from a terminal session in AWS Console.

Why AWS Command-line interface?

AWS Command-line interface provides the best usability and control over AWS services. If there is another way available (AWS Web Console), why do we need a Command-line interface (CLI)?

 

Why AWS CLI

Well, Infrastructure configuration through AWS Web console is quite a difficult and time-consuming process where AWS CLI comes into the picture and makes the configuration quick, easy, and efficient. It not only saves a lot of time but also increases productivity among the working team.

after using aws cli

Benefits of AWS Command-line interface 

One of the most obvious benefits of AWS CLI is the potential to save a significant amount of time. The savings come from easy installations, support of all services from one tool, going beyond GUIs, and using shell scripting to automate processes and commands. The major benefit of AWS CLI mentioned below :

  1. Easy to Install: Before CLI was introduced, we had something called AWS EC2 Application programming tool kit, and installing this tool kit involves several difficult steps. The user has to set up multiple environment Variables while it would be difficult to set up. Instead of this AWS, CLI is just a one-step process.
  2. Supports all AWS services: AWS CLI is compatible with all the services like EC2, RDS, Beanstalk, SQS, and SNS, etc.
  3. Time-Saving: AWS command-line interfaces save a lot of time in installing and managing AWS services. Because all the services are getting managed by commands and also we don’t have to follow traditional method (through web console) to manage services.
  4. Scripting Automation: It’s easy to automate the process of managing and controlling services by writing the script in any programming language.

Working of AWS Command-line interface 

AWS CLI allows you to access files inside the portal through specific commands. It saves a lot of time and offers the ability to automate the entire process of controlling and managing AWS services through scripts. These scripts obtain a fully automated cloud infrastructure.

AWS CLI Working

Using the terminal program, you can begin using all of the AWS Management Console features. It’s as follows:

Linux shells: Use a command shell program such as bash, ZHS, THS to run commands. in operating systems like Linux, macOS, or Unix
Windows Command Line: You can run commands in either the power shell or windows command processor.
Remotely: Remotely run commands on AWS EC2 instances through a remote terminal such as putty, SSH, or AWS Systems Manager.

 

How to install and configure CLI :

AWS Command Line Interface (AWS CLI) helps us interact with various AWS services in the cloud. These include your security credentials, default output format, and the default AWS Region.

Prerequisites : 

  • Python 2 version 2.6.5+ or Python 3 version 3.3+
  • Windows, Linux, macOS, or Unix Operating System

Now let’s install and configure AWS CLI  as shown in the following steps mentioned below:

Step 1. Download and install AWS CLI:  Before going to AWS dashboard, firstly, we have to download the CLI installer on the local machine ( Windows, macOS, Linux ).

Download AWS Installer form Official website

After that, RUN the downloaded MSI installer.

Step 2. Confirm the installation: To confirm the installation process, we must write the command aws --version on the command prompt. If the version is displayed, it indicates that CLI is installed, fortunately.

check if cli installed or not

 

Step 3. Configure AWS CLI: After CLI installation, we have to perform downloading the access key from AWS Console.

For that, go to My Security Credentials  ( Top right ) > choose Access keys > create New Access Key, then download that key to the local machine.

create new access key

Now we can configure AWS CLI using command: aws configure and fill details like AWS keys, region and output format.

  1. AWS Access Key ID [None] : ************
  2. AWS Secret access key [None] : ************
  3. Default Region name [None] : us-east-2

(However, you can choose any region closest to your location)

  1. Default output format [None] : JSON

(When we run the command, it’s going to split out some output, and there are several different options available, like how you want those output printed out. You can get it in JSON, YAML, or text format.)

CLI configuration

Step 4. Create Key Pair through CLI: Now, let create a key pair with the help of the command :aws ec2 create-key-pair --key-name k21academykey (key pair name ) --query 'KeyMaterial' --output text > k21academykey.pem

create key pair through cli

This command will create Key pair in a second, similarly to get it verify, you can write: aws ec2 describe-key-pairs  

If you want to delete the key pair at some instance, you can use the command: aws ec2 delete-key-pair --key-name k21academykey (key pair name )

 

Step 5. Deploy ec2 instance through CLI: Now, in the next step, we are creating and deploying ec2 instance through CLI; before, we have to collect ami- id by going to EC2 instances > launch instance.

collect ami id

After collecting ami-id, you can follow command: aws ec2 run-instances --image-id ami-******* ( write id here )  --instance-type t2.micro --key-name k21academykey (key pair name ) to launch and deploy ec2 instance.

We can also verify the deployed instance by going to EC2 Instances in AWS Portal.

verify deployed ec2 instance

Or with the help of CLI  by writing command: aws ec2 describe-instances

deploy ec2 instance

This showed we have successfully created and deployed the EC2 instance.

Case Study on AWS CLI

Currently, most enterprises are moving towards cloud computing and expanding their infrastructure.  There are Lots of companies reportedly use AWS CLI in their tech stacks. Companies trusting on AWS are mentioned below :

Ordoo-Case Study

  • Ordoo: Ordoo is an app help people to save time collecting their coffee & lunch. It enables customers to order and pay in advance at their favorite cafes and coffee shops, beating the queue and earning loyalty rewards. Ordoo has shown trust in Amazon and using  AWS CLI in their tech stacks.

top hatter- Case Study

  • Tophatter: It brings over 10 million shoppers from worldwide to an online marketplace brimming with lightning-fast live auctions. People can search a few categories on the discovery shopping app, then participate in 90-second auctions for jewelry, electronics, cosmetics, and fashion. Tophatter is also using AWS CLI in their tech stacks.

Other companies reportedly use AWS CLI including Infrastructure, Lancaster solutions, Reef, etc.

Conclusion:

AWS Web Console performs the same action as AWS CLI does, but the difference comes when it’s about quick output in a short period of time. AWS CLI help to control amazon’s public cloud services just by typing commands in the command line. It is configurable in Windows, macOS, and Linux.

Related Links/References

Next Task For You

Begin your journey towards becoming a Certified AWS Solution Architect Associate by joining our FREE Informative Class on Amazon AWS Solution Architect Certification For Beginners & Q/A by clicking on the below image.
Free Masterclass

The post What is AWS Command Line Interface (CLI) | How to Install and Configure appeared first on Cloud Training Program.


Viewing all articles
Browse latest Browse all 1892

Trending Articles