अर्थ TASK-3

Mangal Hansdah
3 min readSep 27, 2021

--

DESCRIPTION:-1. Create a key pair
2. Create a security group
3. Launch an instance using the above
created key pair and security group.
4. Create an EBS volume of 1 GB.
5. The final step is to attach the
above created EBS volume to the
instance you created in the previous steps.

Per-requisites for the practical :

  1. AWS CLI should be installed in the OS
  2. AWS CLI should be configured in the OS

Stepwise Implementation:

Step 1: Create a key pair

  • Key name: MyArthKey
$ aws ec2 create-key-pair --key-name MyArthKey

STEP 2: Create a security group

  • SG name: arth-aws-allowall
  • Description: Allow all traffic for arth aws security group
$ aws ec2 create-security-group \ 
--group-name arth-aws-allowall \
--description "Allow all traffic for arth aws security group"
  • Authorize the security group with the inbound rule
$ aws ec2 authorize-security-group-ingress \
--group-name arth-aws-allowall \
--protocol all \
--cidr 0.0.0.0/0

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

  • Image name: Amazon Linux AMI 2
  • Instance type: t2.micro
  • Count: 1
  • Subnet id: subnet-5d191d35
  • Tags: Name: arth-os
  • Security group: arth-aws-allowall
  • Key name: MyArthKey
$ aws ec2 run-instances \
--image-id ami-0e306788ff2473ccb \
--instance-type t2.micro \
--count 1 \
--subnet-id subnet-5d191d35 \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=arth-os}]' \
--security-group-ids sg-001151b8148c34cc5 \
--key-name MyArthKey

STEP 4: Create an EBS volume of 1 GB

  • Size: 1GB
  • Availability Zone: ap-south-1a
  • Tags: Name: arth-ebs-volume
$ aws ec2 create-volume 
--availability-zone ap-south-1a
--size 1
--tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=arth-ebs-volume}]'

STEP 5: Attach the above created EBS volume to the instance created in the previous steps

  • Instance id: i-0e54836c1b7315dc2
  • Volume id: vol-01984871a464e0f70
  • Device name: /dev/xvdh
$ aws ec2 attach-volume 
--instance-id i-0e54836c1b7315dc2
--volume-id vol-01984871a464e0f70
--device /dev/xvdh

Now our EBS volume is successfully attached to the EC2 instance and we can see the two volumes one if default and the other is created by EBS.

STEP 6: Delete the Setup

Run the following commands to delete the setup

$ aws ec2 detach-volume --instance-id i-0e54836c1b7315dc2 --volume-id vol-01984871a464e0f70$ aws ec2 delete-volume --volume-id vol-01984871a464e0f70$ aws ec2 terminate-instances --instance-ids i-0e54836c1b7315dc2$ aws ec2 delete-security-group --group-name arth-aws-allowall$ aws ec2 delete-key-pair --key-name MyArthKey

Thanks for reading the article. If you really like the article claps are appreciated!!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Mangal Hansdah
Mangal Hansdah

No responses yet

Write a response