Launching AWS instance using AWS-CLI

Objective →

  1. Create a key pair.
  2. Create a security group.
  3. Launch an instance using the above-created security group.
  4. Create an EBS volume of 1 Gb.
  5. Attach the EBS volume with the instance.

Creating a key pair.

aws ec2 create-key-pair --key-name AWS-Keypair --query "KeyMaterial"

Creating a Security Group

aws ec2 create-security-group --group-name <security-group-name> --description "<description>"

Launching Instance using above Security Group and Key Pairs.

aws ec2 run-instances --image-id <ami-id> --count 1 --instance-type t2.micro --key-name <Keypair-name> --security-group-ids <SecurityGroupId> --subnet-id <SubnetId>
Instance Launched.

Creating an EBS volume of size 1 Gb.

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

Attaching the volume with our instance.

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

--

--

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