Skip to content

Instantly share code, notes, and snippets.

@CerebralMastication
Created May 6, 2011 21:03
Show Gist options
  • Save CerebralMastication/959780 to your computer and use it in GitHub Desktop.
Save CerebralMastication/959780 to your computer and use it in GitHub Desktop.
shell script for starting and logging onto an ec2 instance
#!/bin/bash
secGroup="sg-50681d39"
ami="ami-1aad5273"
keyName="ec2ApiTools"
keyLocation="/home/jal/Documents/AWS/ec2ApiTools_rsa_id"
instance_id=$(ec2-run-instances -k $keyName -g $secGroup -t m1.large $ami | awk '/INSTANCE/{print $2}')
echo $instance_id
sleep 30
name=$(ec2-describe-instances $instance_id | awk '/INSTANCE/{print $4}')
echo $name
ssh -i $keyLocation ubuntu@$name -o StrictHostKeyChecking=no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment