Operating AWS using CLI

Janhavi Jain
3 min readOct 19, 2020

--

In order to automate, we need to use the CLI commands. Knowing how to use AWS from command line interface is thus essential if we want to automate or create anything using it’s enormous power.

I’ve concentrated more on the approach of learning how to find the commands behind:

  1. Creating a key pair
  2. Creating a security group
  3. Launching an instance using the above two
  4. Creating an EBS volume of 1 GB
  5. Attaching the EBS volume to the above instance

The first step was, using GUI to explore AWS and understand the arrangement of services and their subservices, in order to understand the order of commands and options for the CLI approach.

aws configuration (IAM user)

I started by making an IAM user using GUI and configuring AWS console installed on my command prompt.

creation of the key pair
  1. This was followed by creating the key pair using “aws create-key-pair — key-name <name>” command.

We got the output as shown in the pic, this confirmed that the key has been successfully created.

GUI confirmation of key creation
creation of the security group

2. The creation of security group was done using “aws ec2 create-security-group — group-name <name> — description <desc>” and the output confirmed it’s creation.

Launching the instance using above key and security group

3. Launching an instance using the above key and security group was done using the elaborate command shown in the image. It follows the logic of our clicks, starting from EC2 service, followed by determining the image id, instance type, number of instances, subnet, security group id and key name we created above.

creating EBS volume of 1 GB

4. Creation of an Elastic Block Storage Volume of 1 GB was again done by following the steps of clicks in GUI.

attaching the volume to the instance

5. Attaching the EBS Volume to the instance using the command shown in the pic.

GUI proof of the CLI execution in AWS (key pair)
GUI proof of CLI creation of EBS attached to instance

As a practice, I like to detach and delete the created services after its usage, in order to avoid getting billed due to any mistakes. I’ve done so as follows:

detaching the EBS volume
deleting the EBS volume
stopping the launched instance after usage

Hope this article was useful!

I would like to thank Mr. Vimal Daga, for teaching the approach to learning in such an effective way.

--

--

Janhavi Jain
Janhavi Jain

Written by Janhavi Jain

Hi there! I write about many technologies like Docker and Hadoop in an easy to understand language. My LinkedIn: https://www.linkedin.com/in/janhavi-jain

No responses yet