Skip to content

Instantly share code, notes, and snippets.

@kerin
Created March 17, 2015 15:29
Show Gist options
  • Save kerin/d6894cbbaae048eb3bc0 to your computer and use it in GitHub Desktop.
Save kerin/d6894cbbaae048eb3bc0 to your computer and use it in GitHub Desktop.
@task
def create_vpc(name='bototest'):
vpcs = ec2.describe_vpcs(Filters=[{'Name': 'tag:Name', 'Values': [name]}])
if not vpcs['Vpcs']:
print 'creating'
vpc_id = ec2.create_vpc(CidrBlock='10.0.0.0/16')['Vpc']['VpcId']
ec2.get_waiter('vpc_available').wait(VpcIds=[vpc_id])
ec2.create_tags(Resources=[vpc_id],
Tags=[{'Key': 'Name', 'Value': name}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment