Created
November 28, 2015 14:33
-
-
Save shrkw/d4ce7321348d72aeb8e6 to your computer and use it in GitHub Desktop.
depends on aws, jq command, and an argument should be image id
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
function run-ec2 { | |
source ~/.virtualenv/CP-2710/bin/activate | |
aws ec2 run-instances --image-id $1 --instance-type t1.micro --key-name oregon > /tmp/run-i | |
aws_id=$(cat /tmp/run-i | jq -r '.Instances | .[] | .InstanceId') | |
echo "aws_id: $aws_id" | |
sleep 10 | |
aws ec2 describe-instances --instance-ids $aws_id > /tmp/run-i | |
aws_ip=$(cat /tmp/run-i | jq -r '.Reservations | .[] | .Instances | .[] | .PublicDnsName') | |
echo "aws_ip: $aws_ip" | |
echo 'ssh -i ~/.ssh/id_rsa.aws.oregon -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ec2-user@$aws_ip' | |
echo 'aws ec2 terminate-instances --instance-ids $aws_id' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment