Created
December 7, 2012 00:27
-
-
Save masayang/4229688 to your computer and use it in GitHub Desktop.
VPC w/ public subnet
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
#! /usr/bin/env python | |
from boto.vpc import VPCConnection | |
from boto.ec2 import get_region | |
EC2_REGION='ap-northeast-1' | |
VPC_CIDR='10.99.0.0/16' | |
PUBLIC_CIDR='10.99.0.0/24' | |
ec2region = get_region(EC2_REGION) | |
conn = VPCConnection(region=ec2region) | |
vpc = conn.create_vpc(VPC_CIDR) | |
igw = conn.create_internet_gateway() | |
conn.attach_internet_gateway(igw.id, vpc.id) | |
subnet = conn.create_subnet(vpc.id, PUBLIC_CIDR) | |
route_table = conn.get_all_route_tables( | |
filters=[("vpc-id", vpc.id)])[0] | |
conn.create_route(route_table.id, '0.0.0.0/0', gateway_id=igw.id) | |
print "vpc-id %s created" % vpc.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment