Last active
June 21, 2019 08:06
-
-
Save pictolearn/0e333916ba168188927d9fa9ec7fa5a2 to your computer and use it in GitHub Desktop.
Launch,list and terminate_EC2_instances_using_amzon_command_line_interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Launches an instance | |
# aws ec2 run-instances \ | |
# --image-id <ami-xxxxx> \ | |
# --count 1 \ | |
# --instance-type t2.micro \ | |
# --key-name <your KeyPair> \ | |
# --security-group-ids <group_id> \ | |
# --subnet-id <your subnet id> | |
aws ec2 run-instances --image-id ami-0cc96feef8c6bbff3 --count 1 --instance-type t2.micro --key-name pictolearn-ec2 --security-group-ids sg-0bc5999645783c843 --subnet-id subnet-76f2c879 | |
#Lists the instances | |
aws ec2 describe-instances --filters "Name=instance-type,Values=t2.micro" --query "Reservations[].Instances[].InstanceId" | |
## The following command lists your instances that were launched using any of the following AMIs: ami-x0123456, ami-y0123456, and ami-z0123456. | |
aws ec2 describe-instances --filters "Name=image-id,Values=ami-x0123456,ami-y0123456,ami-z0123456" | |
#terminates instance | |
aws ec2 terminate-instances --instance-ids <your instance_id> | |
## kills the instance respectively | |
###aws ec2 terminate-instances --instance-ids i-5203422c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment