AWS CLI EC2 Script
AWS CLI EC2 Script
aws ec2 create-key-pair --key-name NameOfTheKeyPair --query 'KeyMaterial' --output text > NameOfTheKeyPair.pem
CMD:-2:
Aws ec2 describe-key-pairs
CMD:-3:
aws ec2 create-key-pair --key-name MyKeyPair --query 'KeyMaterial' --output text | out-file -encoding ascii -filepath
MyKeyPair.pem (optional)
CMD:-4:
aws ec2 describe-security-groups
CMD:-5:
Aws ec2 describe-vpcs
CMD:-6:
CMD:-7:
CMD:-8:
CMD:-9:
AMI ID:
Security groupid:
Subnet Id: for this go manutally and search VPC and then go to subject make sure you are in Mumbai region only.
CMD:-10:
aws ec2 run-instances --image-id ami-xxxxxxxx --count 1 --instance-type t2.micro --key-name MyKeyPair --security-group-
ids sg-903004f8 --subnet-id subnet-6e7f829e
CMD:11:
Add tags to EC2
o AMI - Ubuntu
o Instance Type - t2.micro
o Security Group Inbound Ports - 22, 80, 443
o Region – Mumbai
o Tag - "Company: Infosys"