Created
January 27, 2014 19:37
-
-
Save sunglassatnight/8655771 to your computer and use it in GitHub Desktop.
fab
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
from fabric.api import * | |
import boto.ec2 | |
from clom import clom | |
def create_vm(): | |
conn = boto.ec2.connect_to_region( | |
'us-west-2', | |
aws_access_key_id='AKIAJAJ7JAFYVAYKDXPA', | |
aws_secret_access_key='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') | |
conn.run_instances( | |
'ami-c6cc43f6', | |
key_name='logan', | |
instance_type='m1.small', | |
security_groups=['launch-wizard-1']) | |
reservations = conn.get_all_reservations() | |
instances = reservations[-1].instances | |
inst = instances[0] | |
print 'The ip address is: %s' % inst.ip_address | |
print 'The default username is "ubuntu"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on line 12, the
run_instances
call will return the reservation it created. You should save this into a variable and then just use theinstances
property. This will also eliminate the need to make theget_all_reservations
call.