Performing Some Task On AWS Cloud Using CLI(Command Line Interface).

Raj Kumar Vishwakarma
4 min readOct 23, 2020

Task Description — AWS 👨🏻‍💻

đź”… Create a key pair

đź”… Create a security group

đź”… Launch an instance using the above created key pair and security group.

đź”… Create an EBS volume of 1 GB.

đź”… The final step is to attach the above created EBS volume to the instance you created in the previous steps.

Before we start the above task first we have to install AWS CLI version 2 from the link-

https://awscli.amazonaws.com/AWSCLIV2.msi

Now let’s configure the AWS on CLI by typing command

# aws configure

AWS Access Key ID and Secret Access Key we get from IAM service of AWS

  1. Create a Key Pair

A key pair, consisting of a private key and a public key, is a set of security credentials that you use to prove your identity when connecting to an instance

Let’s Move to our first task i.e. we have to create a key pair. For this we have the command:

# aws ec2 create-key-pair — key-name <key name>

Now let’s cross check on the WebUI for the confirmation.

2.Create a security group

A security group acts as a virtual firewall for your EC2 instances to control incoming and outgoing traffic. Inbound rules control the incoming traffic to your instance, and outbound rules control the outgoing traffic from your instance.

for creating Security group we have the command-

# aws ec2 create-security-group — group-name <name> — description “ Description”

Now cross check on the WebUI for the confirmation that Security Group is successfully created.

Now i am adding inbound rule to this security group which state that i am the only one(my IP) who can access the instance via ssh (Remote login), for this we have the command-

#aws ec2 authorize-security-group-ingress — protocol tcp — port 22 —group-name <SG name> — cidr <my IP>

Lets cross check on WebUI for the confirmation that rule is successfully added or not.

3.Launch an instance using the above created key pair and security group

for launching the instance we have the command-

# aws ec2 run-instance — image-id <AMI ID> — instance-type t2.micro — count 1 — subnet-id <subnet id> — security-group-ids <sg id> — key-name <key name>

Now lets cross check on the WebUI for the confirmation

4.Create an EBS volume of 1 GB

An Amazon EBS volume is a durable, block-level storage device that you can attach to your instances.

for creating the EBS volume of 1 GB we have the command-

# aws ec2 create-volume — availabilty-zone <AZ >— size <size in GB>

Lets cross check WebUI for the confirmation

5.The final step is to attach the above created EBS volume to the instance you created in the previous steps

To attach the above created EBS volume of 1GB to our instance we have the command :

# aws ec2-attach-volume — device /dev/sdf — instance-id <instance id> — volume-id <vol id>

Now lets cross check on the WebUI for the confirmation

Resource :

For more information ping to me on LinkedIn-

--

--