0% found this document useful (0 votes)
25 views9 pages

7 Useful AWS EC2 CLI Commands

Uploaded by

jaichandu136
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views9 pages

7 Useful AWS EC2 CLI Commands

Uploaded by

jaichandu136
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

7 USEFUL

AWS EC2 CLI COMMANDS


1. To retrieve information about
EC2 Instances

a. aws ec2 describe-instances


b. aws ec2 describe-instances
--instance-ids <i-xxxxxxxxx>
2. To Start/Stop/Terminate
EC2 Instances

a. aws ec2 start-instances


--instances-ids i-xxxxxxxxx
b. aws ec2 stop-instances
--instances-ids i-xxxxxxxxx
c. aws ec2 terminate-instances
--instances-ids i-xxxxxxxxx
3. To generate a new key pair
for SSH access

aws ec2 create-key-pair


--key-name MyKeyPairName
4. To create a new security group

aws ec2 create-security-group


--group-name my-sg
--description "My security group"
5. To Create an Amazon Machine
Image (AMI) from an EC2 instance.

aws ec2 create-image --instance-id


i-xxxxxxxxxxxxxxxx
--name "My server" --description
"An AMI for my server"`
6. To create/delete ebs volumes

a. aws ec2 create-volume --availability-


zone ap-south-1a --size 50
--volume-type gp3`

b. aws ec2 delete-volume --volume-id


vol-xxxxxxxxxxx
7. To Launch a new EC2 Instance

aws ec2 run-instances --image-id


ami-xxxxxxxxxxxxxxxx --count 1
--instance-type t2.micro
--key-name my-key-pair
--security-group-ids sg-xxxxxxxxxx

You might also like