Instance Launch using AWS CLI

Samkit Shah
2 min readOct 13, 2020

There are three ways by which you can provision your AWS:

  1. AWS GUI
  2. AWS CLI
  3. Programming SDK

Here we are going to use AWS CLI for launching infrastructure.

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.

To create a key pair

aws ec2 create key-pair --key-name samkit

To create a security group

aws ec2 create-security-group --description "this is sg1" --group-name firewallaws

To create an EBS volume of 1GB

aws ec2 create-volume --availability-zone ap-south-1a --size 1

Launch Instance

aws ec2 run-instances --image-id  ami-0e306788ff2473ccb --instance-type t2.micro --count 1 --subnet-id subnet-60f1cb08 --security-group-ids sg-0dbdab2674bb98978 --key-name samkit

Attach Volume with the instance

aws ec2 attach-volume --volume-id vol-05fc6cc48bea6e60a --instance-id i-0cd24121417ae57f9 --device /dev/sdf

Launched successfully!

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

--

--

Samkit Shah
Samkit Shah

Written by Samkit Shah

Machine Learning | Deep Learning | DevOps | MLOps | Cloud Computing | BigData

No responses yet