Last active
August 29, 2015 13:56
-
-
Save jonmorehouse/9316547 to your computer and use it in GitHub Desktop.
EC2 one liners for setting up / breaking down machines
This file contains hidden or 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
#!/usr/local/bin/bash | |
# create an ec2-instance and grab the instance id | |
instance_id=$(ec2-run-instances -g development -t t1.micro -k master $EC2_UBUNTU_AMI | grep INSTANCE | awk '{ print $2 }') | |
# create a tag for this instance as needed | |
ec2-create-tags -t Name=development $instance_id | |
# grab instance_id by tag | |
instance_id=$(ec2-describe-instances --filter "tag:Name=development" | grep INSTANCE | awk '{ print $2 }') | |
# grab all running instances (ids) | |
instance_id=$(ec2-describe-instances --filter "instance-state-name=running" | grep INSTANCE | awk '{ print $2 }') | |
# now start this instance | |
ec2-start-instances $instance_id | |
# stop the same instance | |
ec2-stop-instances $instance_id | |
# terminate the instance | |
ec2-terminate-instances $instance_id | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment