Skip to content

Instantly share code, notes, and snippets.

@sunglassatnight
Created January 27, 2014 21:32
Show Gist options
  • Save sunglassatnight/8657770 to your computer and use it in GitHub Desktop.
Save sunglassatnight/8657770 to your computer and use it in GitHub Desktop.
from fabric.api import *
import boto.ec2
import time
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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')
reservation = conn.run_instances(
'ami-c6cc43f6',
key_name='logan',
instance_type='m1.small',
security_groups=['launch-wizard-1'])
instances = reservation.instances
inst = instances[0]
while True:
inst.update()
if inst.state_code == 16:
print 'The ip address is: %s' % inst.ip_address
print 'The default username is "ubuntu"'
break
else:
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment