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

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

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store