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. This post 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)

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 process by writing the script in the programming language you are familiar with. That script allows deploying multiple resources without going 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)?

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 saves a lot of time and increases productivity among the working team.

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 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.

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.

Also Check: Our previous blog post on AWS Elastic Load Balancer.

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 ).

After that, RUN the downloaded MSI installer.

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

Check Out: Our blog post on AWS VPC.

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

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

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.)

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

This command will create Key pair in a second, similarly to get it to 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 )

Also Read: Our blog post on AWS Cloud Security.

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.

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.

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

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

Also Check: Our blog post on AWS Storage.

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: Ordoo is an app that helps people to save time collecting their coffee & lunch. It enables customers to order and pay in advance at their favourite 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.
  • Tophatter: It brings over 10 million shoppers 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 jewellery, 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 by typing commands in the command line. It is configurable in Windows, macOS, and Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *