Created
August 1, 2012 06:16
-
-
Save slackorama/3224213 to your computer and use it in GitHub Desktop.
Boto and ec2
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
import boto | |
ec2 = boto.connect_ec2() | |
key_pair = ec2.create_key_pair('ec2-sample-key') # only needs to be done once | |
key_pair.save('/Users/patrick/.ssh') | |
reservation = ec2.run_instances(image_id='ami-bb709dd2', key_name='ec2-sample-key') | |
# Wait a minute or two while it boots | |
for r in ec2.get_all_instances(): | |
if r.id == reservation.id: | |
break | |
print r.instances[0].public_dns_name # output: ec2-184-73-24-97.compute-1.amazonaws.com | |
$ chmod 600 ~/.ssh/ec2-sample-key.pem | |
$ ssh -i ~/.ssh/ec2-sample-key.pem [email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment