Launch EC-2 instance & attach EBS volume using AWS CLI

Harsh Agrawal
3 min readMar 20, 2021

In this blog we will cover

πŸ“Œ 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.

Firstly we need to install aws cli on our machine where we want to run aws commands. After installing we need to configure our machine by the command

aws configure 
aws configure

Here we get Access Key Id and Secret key Id by configuring IAM(Identity Access Management) AWS

  1. Creating a key-pair
aws ec2 create-key-pair --key-name "cli-task3"

We can verify the results of above command by going to Key pair section of ec2 dashboard

2. Making a security-groups

aws ec2 create-security-group --description cli-2-task --group-name cli-2-sg
Verify on AWS GUI

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

4. Creating an EBS volume of 1 GB.

5. Attaching the above created EBS volume to the EC2 instance

Thank you

If you have any doubt, can message me on Linkedin

Harsh Agrawal

--

--