2017-12-29 03:00:53 +00:00
|
|
|
import boto
|
2017-12-27 19:17:59 +00:00
|
|
|
import boto3
|
2019-05-25 10:18:16 +00:00
|
|
|
from boto import vpc as boto_vpc
|
2017-12-29 03:00:53 +00:00
|
|
|
from moto import mock_ec2, mock_ec2_deprecated
|
2017-12-27 19:17:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
@mock_ec2
|
|
|
|
def setup_networking():
|
|
|
|
ec2 = boto3.resource('ec2', region_name='us-east-1')
|
|
|
|
vpc = ec2.create_vpc(CidrBlock='10.11.0.0/16')
|
|
|
|
subnet1 = ec2.create_subnet(
|
|
|
|
VpcId=vpc.id,
|
|
|
|
CidrBlock='10.11.1.0/24',
|
|
|
|
AvailabilityZone='us-east-1a')
|
|
|
|
subnet2 = ec2.create_subnet(
|
|
|
|
VpcId=vpc.id,
|
|
|
|
CidrBlock='10.11.2.0/24',
|
|
|
|
AvailabilityZone='us-east-1b')
|
|
|
|
return {'vpc': vpc.id, 'subnet1': subnet1.id, 'subnet2': subnet2.id}
|
2017-12-29 03:00:53 +00:00
|
|
|
|
|
|
|
@mock_ec2_deprecated
|
|
|
|
def setup_networking_deprecated():
|
2019-05-25 10:18:16 +00:00
|
|
|
conn = boto_vpc.connect_to_region('us-east-1')
|
2017-12-29 03:00:53 +00:00
|
|
|
vpc = conn.create_vpc("10.11.0.0/16")
|
2019-05-25 10:18:16 +00:00
|
|
|
subnet1 = conn.create_subnet(
|
|
|
|
vpc.id,
|
|
|
|
"10.11.1.0/24",
|
|
|
|
availability_zone='us-east-1a')
|
|
|
|
subnet2 = conn.create_subnet(
|
|
|
|
vpc.id,
|
|
|
|
"10.11.2.0/24",
|
|
|
|
availability_zone='us-east-1b')
|
2017-12-29 03:00:53 +00:00
|
|
|
return {'vpc': vpc.id, 'subnet1': subnet1.id, 'subnet2': subnet2.id}
|