Latest Updates

Launch Amazon AWS Instance Using AWS CLI

 


Task Objective:-

What is Key-Pair?

What is the Security Group?

What is the EC2 Instance?

What is the EBS Volume?

Let’s Get Started

aws configure

aws ec2 create-key-pair  -- key-name “KEY_Name”

 

aws ec2 create-security-group -- description “little description” -- group-name “any name” --vpc-id “your VPC id”



Now we have to set some protocols so specific users can connect instances through SSH.


you can see we have allowed all the traffic from all IPs from port 22 so anyone can connect to instance you can give specific IP to allow as well.


aws ec2 run-instances -- image-id “Image id get it from UI” -- instance-type “any flavor of instance Ex. t2.micro” -- key-name “your Key Name” -- security-group-ids “security group id” -- subnet-id “your subnet id”  -- count “number of instances”


aws ec2 create-volume --availability-zone “ap-south-1a” -- volume-type “gp2” --size 1 --tag-specifications ResourceType=”volume”,Tags=[{Key=name,Value=CMD_Volume}]

 


aws ec2 attach-volume -- instance-id “your instance id” -- volume-id “your volume id” -- device “/dev/device name Ex. sdh”






 

No comments