Add more availability regions and implement default VPC (#773)

Fix filter name for availability zone

Fix bug assuming dict keys are ordered

Fix tests

Fix tests

Fix bug
This commit is contained in:
Taro Sato 2017-01-11 17:37:57 -08:00 committed by Steve Pulec
commit 02324ad708
13 changed files with 218 additions and 142 deletions

View file

@ -661,13 +661,14 @@ def test_vpc_single_instance_in_subnet():
)
vpc_conn = boto.vpc.connect_to_region("us-west-1")
vpc = vpc_conn.get_all_vpcs()[0]
vpc = vpc_conn.get_all_vpcs(filters={'cidrBlock': '10.0.0.0/16'})[0]
vpc.cidr_block.should.equal("10.0.0.0/16")
# Add this once we implement the endpoint
# vpc_conn.get_all_internet_gateways().should.have.length_of(1)
subnet = vpc_conn.get_all_subnets()[0]
subnet = vpc_conn.get_all_subnets(filters={'vpcId': vpc.id})[0]
subnet.vpc_id.should.equal(vpc.id)
ec2_conn = boto.ec2.connect_to_region("us-west-1")
@ -1355,7 +1356,7 @@ def test_vpc_gateway_attachment_creation_should_attach_itself_to_vpc():
)
vpc_conn = boto.vpc.connect_to_region("us-west-1")
vpc = vpc_conn.get_all_vpcs()[0]
vpc = vpc_conn.get_all_vpcs(filters={'cidrBlock': '10.0.0.0/16'})[0]
igws = vpc_conn.get_all_internet_gateways(
filters={'attachment.vpc-id': vpc.id}
)

View file

@ -1,5 +1,7 @@
from __future__ import unicode_literals
import boto
import boto.ec2
import boto3
import sure # noqa
from moto import mock_ec2
@ -9,16 +11,39 @@ from moto import mock_ec2
def test_describe_regions():
conn = boto.connect_ec2('the_key', 'the_secret')
regions = conn.get_all_regions()
regions.should.have.length_of(8)
regions[0].name.should.equal('eu-west-1')
regions[0].endpoint.should.equal('ec2.eu-west-1.amazonaws.com')
regions.should.have.length_of(14)
for region in regions:
region.endpoint.should.contain(region.name)
@mock_ec2
def test_availability_zones():
# Just testing us-east-1 for now
conn = boto.connect_ec2('the_key', 'the_secret')
zones = conn.get_all_zones()
zones.should.have.length_of(5)
zones[0].name.should.equal('us-east-1a')
zones[0].region_name.should.equal('us-east-1')
regions = conn.get_all_regions()
for region in regions:
conn = boto.ec2.connect_to_region(region.name)
if conn is None:
continue
for zone in conn.get_all_zones():
zone.name.should.contain(region.name)
@mock_ec2
def test_boto3_describe_regions():
ec2 = boto3.client('ec2', 'us-east-1')
resp = ec2.describe_regions()
resp['Regions'].should.have.length_of(14)
for rec in resp['Regions']:
rec['Endpoint'].should.contain(rec['RegionName'])
@mock_ec2
def test_boto3_availability_zones():
ec2 = boto3.client('ec2', 'us-east-1')
resp = ec2.describe_regions()
regions = [r['RegionName'] for r in resp['Regions']]
for region in regions:
conn = boto3.client('ec2', region)
resp = conn.describe_availability_zones()
for rec in resp['AvailabilityZones']:
rec['ZoneName'].should.contain(region)

View file

@ -52,15 +52,12 @@ def test_key_pairs_create_two():
kp = conn.create_key_pair('bar')
assert kp.material.startswith('---- BEGIN RSA PRIVATE KEY ----')
kps = conn.get_all_key_pairs()
assert len(kps) == 2
# on Python 3, these are reversed for some reason
if six.PY3:
return
assert kps[0].name == 'foo'
assert kps[1].name == 'bar'
kps.should.have.length_of(2)
[i.name for i in kps].should.contain('foo')
[i.name for i in kps].should.contain('bar')
kps = conn.get_all_key_pairs('foo')
assert len(kps) == 1
assert kps[0].name == 'foo'
kps.should.have.length_of(1)
kps[0].name.should.equal('foo')
@mock_ec2

View file

@ -7,41 +7,37 @@ from moto import mock_ec2
@mock_ec2
def test_default_network_acl_created_with_vpc():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
all_network_acls = conn.get_all_network_acls()
all_network_acls.should.have.length_of(1)
@mock_ec2
def test_network_acls():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
network_acl = conn.create_network_acl(vpc.id)
all_network_acls = conn.get_all_network_acls()
all_network_acls.should.have.length_of(2)
@mock_ec2
def test_new_subnet_associates_with_default_network_acl():
@mock_ec2
def test_network_acls():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
network_acl = conn.create_network_acl(vpc.id)
all_network_acls = conn.get_all_network_acls()
all_network_acls.should.have.length_of(3)
@mock_ec2
def test_new_subnet_associates_with_default_network_acl():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.get_all_vpcs()[0]
subnet = conn.create_subnet(vpc.id, "10.0.0.0/18")
all_network_acls = conn.get_all_network_acls()
all_network_acls.should.have.length_of(1)
acl = all_network_acls[0]
acl.associations.should.have.length_of(1)
acl.associations[0].subnet_id.should.equal(subnet.id)
acl.associations.should.have.length_of(4)
[a.subnet_id for a in acl.associations].should.contain(subnet.id)
@mock_ec2
def test_network_acl_entries():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -55,7 +51,7 @@ def test_network_acl_entries():
)
all_network_acls = conn.get_all_network_acls()
all_network_acls.should.have.length_of(2)
all_network_acls.should.have.length_of(3)
test_network_acl = next(na for na in all_network_acls
if na.id == network_acl.id)
@ -68,7 +64,6 @@ def test_network_acl_entries():
@mock_ec2
def test_associate_new_network_acl_with_subnet():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
subnet = conn.create_subnet(vpc.id, "10.0.0.0/18")
@ -77,7 +72,7 @@ def test_associate_new_network_acl_with_subnet():
conn.associate_network_acl(network_acl.id, subnet.id)
all_network_acls = conn.get_all_network_acls()
all_network_acls.should.have.length_of(2)
all_network_acls.should.have.length_of(3)
test_network_acl = next(na for na in all_network_acls
if na.id == network_acl.id)
@ -88,28 +83,26 @@ def test_associate_new_network_acl_with_subnet():
@mock_ec2
def test_delete_network_acl():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
subnet = conn.create_subnet(vpc.id, "10.0.0.0/18")
network_acl = conn.create_network_acl(vpc.id)
all_network_acls = conn.get_all_network_acls()
all_network_acls.should.have.length_of(2)
all_network_acls.should.have.length_of(3)
any(acl.id == network_acl.id for acl in all_network_acls).should.be.ok
conn.delete_network_acl(network_acl.id)
updated_network_acls = conn.get_all_network_acls()
updated_network_acls.should.have.length_of(1)
updated_network_acls.should.have.length_of(2)
any(acl.id == network_acl.id for acl in updated_network_acls).shouldnt.be.ok
@mock_ec2
def test_network_acl_tagging():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
network_acl = conn.create_network_acl(vpc.id)
@ -125,4 +118,3 @@ def test_network_acl_tagging():
if na.id == network_acl.id)
test_network_acl.tags.should.have.length_of(1)
test_network_acl.tags["a key"].should.equal("some value")

View file

@ -17,7 +17,7 @@ def test_route_tables_defaults():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
all_route_tables = conn.get_all_route_tables()
all_route_tables = conn.get_all_route_tables(filters={'vpc-id': vpc.id})
all_route_tables.should.have.length_of(1)
main_route_table = all_route_tables[0]
@ -33,7 +33,7 @@ def test_route_tables_defaults():
vpc.delete()
all_route_tables = conn.get_all_route_tables()
all_route_tables = conn.get_all_route_tables(filters={'vpc-id': vpc.id})
all_route_tables.should.have.length_of(0)
@ -43,7 +43,7 @@ def test_route_tables_additional():
vpc = conn.create_vpc("10.0.0.0/16")
route_table = conn.create_route_table(vpc.id)
all_route_tables = conn.get_all_route_tables()
all_route_tables = conn.get_all_route_tables(filters={'vpc-id': vpc.id})
all_route_tables.should.have.length_of(2)
all_route_tables[0].vpc_id.should.equal(vpc.id)
all_route_tables[1].vpc_id.should.equal(vpc.id)
@ -67,7 +67,7 @@ def test_route_tables_additional():
conn.delete_route_table(route_table.id)
all_route_tables = conn.get_all_route_tables()
all_route_tables = conn.get_all_route_tables(filters={'vpc-id': vpc.id})
all_route_tables.should.have.length_of(1)
with assert_raises(EC2ResponseError) as cm:
@ -88,11 +88,11 @@ def test_route_tables_filters_standard():
route_table2 = conn.create_route_table(vpc2.id)
all_route_tables = conn.get_all_route_tables()
all_route_tables.should.have.length_of(4)
all_route_tables.should.have.length_of(5)
# Filter by main route table
main_route_tables = conn.get_all_route_tables(filters={'association.main':'true'})
main_route_tables.should.have.length_of(2)
main_route_tables.should.have.length_of(3)
main_route_table_ids = [route_table.id for route_table in main_route_tables]
main_route_table_ids.should_not.contain(route_table1.id)
main_route_table_ids.should_not.contain(route_table2.id)
@ -131,7 +131,7 @@ def test_route_tables_filters_associations():
association_id3 = conn.associate_route_table(route_table2.id, subnet3.id)
all_route_tables = conn.get_all_route_tables()
all_route_tables.should.have.length_of(3)
all_route_tables.should.have.length_of(4)
# Filter by association ID
association1_route_tables = conn.get_all_route_tables(filters={'association.route-table-association-id':association_id1})
@ -160,7 +160,7 @@ def test_route_table_associations():
route_table = conn.create_route_table(vpc.id)
all_route_tables = conn.get_all_route_tables()
all_route_tables.should.have.length_of(2)
all_route_tables.should.have.length_of(3)
# Refresh
route_table = conn.get_all_route_tables(route_table.id)[0]
@ -232,7 +232,7 @@ def test_route_table_replace_route_table_association():
route_table2 = conn.create_route_table(vpc.id)
all_route_tables = conn.get_all_route_tables()
all_route_tables.should.have.length_of(3)
all_route_tables.should.have.length_of(4)
# Refresh
route_table1 = conn.get_all_route_tables(route_table1.id)[0]
@ -330,14 +330,14 @@ def test_route_table_get_by_tag_boto3():
def test_routes_additional():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
main_route_table = conn.get_all_route_tables()[0]
main_route_table = conn.get_all_route_tables(filters={'vpc-id': vpc.id})[0]
local_route = main_route_table.routes[0]
igw = conn.create_internet_gateway()
ROUTE_CIDR = "10.0.0.4/24"
conn.create_route(main_route_table.id, ROUTE_CIDR, gateway_id=igw.id)
main_route_table = conn.get_all_route_tables()[0] # Refresh route table
main_route_table = conn.get_all_route_tables(filters={'vpc-id': vpc.id})[0] # Refresh route table
main_route_table.routes.should.have.length_of(2)
new_routes = [route for route in main_route_table.routes if route.destination_cidr_block != vpc.cidr_block]
@ -351,7 +351,7 @@ def test_routes_additional():
conn.delete_route(main_route_table.id, ROUTE_CIDR)
main_route_table = conn.get_all_route_tables()[0] # Refresh route table
main_route_table = conn.get_all_route_tables(filters={'vpc-id': vpc.id})[0] # Refresh route table
main_route_table.routes.should.have.length_of(1)
new_routes = [route for route in main_route_table.routes if route.destination_cidr_block != vpc.cidr_block]

View file

@ -37,7 +37,7 @@ def test_create_and_describe_security_group():
cm.exception.request_id.should_not.be.none
all_groups = conn.get_all_security_groups()
all_groups.should.have.length_of(2) # The default group gets created automatically
all_groups.should.have.length_of(3) # The default group gets created automatically
group_names = [group.name for group in all_groups]
set(group_names).should.equal(set(["default", "test security group"]))
@ -57,7 +57,7 @@ def test_create_security_group_without_description_raises_error():
def test_default_security_group():
conn = boto.ec2.connect_to_region('us-east-1')
groups = conn.get_all_security_groups()
groups.should.have.length_of(1)
groups.should.have.length_of(2)
groups[0].name.should.equal("default")
@ -98,7 +98,7 @@ def test_create_two_security_groups_with_same_name_in_different_vpc():
all_groups = conn.get_all_security_groups()
all_groups.should.have.length_of(3)
all_groups.should.have.length_of(4)
group_names = [group.name for group in all_groups]
# The default group is created automatically
set(group_names).should.equal(set(["default", "test security group"]))
@ -110,7 +110,7 @@ def test_deleting_security_groups():
security_group1 = conn.create_security_group('test1', 'test1')
conn.create_security_group('test2', 'test2')
conn.get_all_security_groups().should.have.length_of(3) # We need to include the default security group
conn.get_all_security_groups().should.have.length_of(4)
# Deleting a group that doesn't exist should throw an error
with assert_raises(EC2ResponseError) as cm:
@ -127,11 +127,11 @@ def test_deleting_security_groups():
ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the DeleteSecurityGroup operation: Request would have succeeded, but DryRun flag is set')
conn.delete_security_group('test2')
conn.get_all_security_groups().should.have.length_of(2)
conn.get_all_security_groups().should.have.length_of(3)
# Delete by group id
conn.delete_security_group(group_id=security_group1.id)
conn.get_all_security_groups().should.have.length_of(1)
conn.get_all_security_groups().should.have.length_of(2)
@mock_ec2
@ -267,6 +267,7 @@ def test_authorize_other_group_egress_and_revoke():
sg01.revoke_egress(IpPermissions=[ip_permission])
sg01.ip_permissions_egress.should.have.length_of(1)
@mock_ec2
def test_authorize_group_in_vpc():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -316,7 +317,7 @@ def test_get_all_security_groups():
resp[0].id.should.equal(sg1.id)
resp = conn.get_all_security_groups()
resp.should.have.length_of(3) # We need to include the default group here
resp.should.have.length_of(4)
@mock_ec2
@ -376,7 +377,7 @@ def test_authorize_all_protocols_with_no_port_specification():
sg.rules[0].from_port.should.equal(None)
sg.rules[0].to_port.should.equal(None)
'''
Boto3
'''

View file

@ -16,17 +16,18 @@ from moto import mock_cloudformation, mock_ec2
@mock_ec2
def test_subnets():
ec2 = boto.connect_ec2('the_key', 'the_secret')
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
subnet = conn.create_subnet(vpc.id, "10.0.0.0/18")
all_subnets = conn.get_all_subnets()
all_subnets.should.have.length_of(1)
all_subnets.should.have.length_of(1 + len(ec2.get_all_zones()))
conn.delete_subnet(subnet.id)
all_subnets = conn.get_all_subnets()
all_subnets.should.have.length_of(0)
all_subnets.should.have.length_of(0 + len(ec2.get_all_zones()))
with assert_raises(EC2ResponseError) as cm:
conn.delete_subnet(subnet.id)
@ -59,7 +60,7 @@ def test_subnet_tagging():
tag.value.should.equal("some value")
# Refresh the subnet
subnet = conn.get_all_subnets()[0]
subnet = conn.get_all_subnets(subnet_ids=[subnet.id])[0]
subnet.tags.should.have.length_of(1)
subnet.tags["a key"].should.equal("some value")
@ -76,22 +77,32 @@ def test_subnet_should_have_proper_availability_zone_set():
def test_default_subnet():
ec2 = boto3.resource('ec2', region_name='us-west-1')
# Create the default VPC
default_vpc = ec2.create_vpc(CidrBlock='172.31.0.0/16')
default_vpc = list(ec2.vpcs.all())[0]
default_vpc.cidr_block.should.equal('172.31.0.0/16')
default_vpc.reload()
default_vpc.is_default.should.be.ok
subnet = ec2.create_subnet(VpcId=default_vpc.id, CidrBlock='172.31.0.0/20', AvailabilityZone='us-west-1a')
subnet.reload()
subnet.map_public_ip_on_launch.should.be.ok
subnet.map_public_ip_on_launch.shouldnt.be.ok
@mock_ec2
def test_non_default_subnet():
ec2 = boto3.resource('ec2', region_name='us-west-1')
vpc_cli = boto.vpc.connect_to_region('us-west-1')
# Create the default VPC
ec2.create_vpc(CidrBlock='172.31.0.0/16')
# Create the non default VPC
vpc = vpc_cli.create_vpc("10.0.0.0/16")
vpc.is_default.shouldnt.be.ok
subnet = vpc_cli.create_subnet(vpc.id, "10.0.0.0/24")
subnet = vpc_cli.get_all_subnets(subnet_ids=[subnet.id])[0]
subnet.mapPublicIpOnLaunch.should.equal('false')
@mock_ec2
def test_boto3_non_default_subnet():
ec2 = boto3.resource('ec2', region_name='us-west-1')
# Create the non default VPC
vpc = ec2.create_vpc(CidrBlock='10.0.0.0/16')
@ -108,10 +119,9 @@ def test_modify_subnet_attribute():
ec2 = boto3.resource('ec2', region_name='us-west-1')
client = boto3.client('ec2', region_name='us-west-1')
# Create the default VPC
ec2.create_vpc(CidrBlock='172.31.0.0/16')
# Get the default VPC
vpc = list(ec2.vpcs.all())[0]
vpc = ec2.create_vpc(CidrBlock='10.0.0.0/16')
subnet = ec2.create_subnet(VpcId=vpc.id, CidrBlock='10.0.0.0/24', AvailabilityZone='us-west-1a')
# 'map_public_ip_on_launch' is set when calling 'DescribeSubnets' action
@ -120,11 +130,15 @@ def test_modify_subnet_attribute():
# For non default subnet, attribute value should be 'False'
subnet.map_public_ip_on_launch.shouldnt.be.ok
client.modify_subnet_attribute(SubnetId=subnet.id, MapPublicIpOnLaunch={'Value': False})
subnet.reload()
subnet.map_public_ip_on_launch.shouldnt.be.ok
client.modify_subnet_attribute(SubnetId=subnet.id, MapPublicIpOnLaunch={'Value': True})
subnet.reload()
subnet.map_public_ip_on_launch.should.be.ok
@mock_ec2
def test_modify_subnet_attribute_validation():
ec2 = boto3.resource('ec2', region_name='us-west-1')
@ -135,8 +149,10 @@ def test_modify_subnet_attribute_validation():
with assert_raises(ParamValidationError):
client.modify_subnet_attribute(SubnetId=subnet.id, MapPublicIpOnLaunch={'Value': 'invalid'})
@mock_ec2
def test_get_subnets_filtering():
ec2 = boto.ec2.connect_to_region('us-west-1')
conn = boto.vpc.connect_to_region('us-west-1')
vpcA = conn.create_vpc("10.0.0.0/16")
subnetA = conn.create_subnet(vpcA.id, "10.0.0.0/24", availability_zone='us-west-1a')
@ -145,7 +161,7 @@ def test_get_subnets_filtering():
subnetB2 = conn.create_subnet(vpcB.id, "10.0.1.0/24", availability_zone='us-west-1b')
all_subnets = conn.get_all_subnets()
all_subnets.should.have.length_of(3)
all_subnets.should.have.length_of(3 + len(ec2.get_all_zones()))
# Filter by VPC ID
subnets_by_vpc = conn.get_all_subnets(filters={'vpc-id': vpcB.id})
@ -181,9 +197,9 @@ def test_get_subnets_filtering():
set([subnet.id for subnet in subnets_by_az]).should.equal(set([subnetB1.id]))
# Filter by defaultForAz
subnets_by_az = conn.get_all_subnets(filters={'defaultForAz': "true"})
subnets_by_az.should.have.length_of(1)
set([subnet.id for subnet in subnets_by_az]).should.equal(set([subnetA.id]))
subnets_by_az.should.have.length_of(len(conn.get_all_zones()))
# Unsupported filter
conn.get_all_subnets.when.called_with(filters={'not-implemented-filter': 'foobar'}).should.throw(NotImplementedError)

View file

@ -21,12 +21,12 @@ def test_vpcs():
vpc.cidr_block.should.equal('10.0.0.0/16')
all_vpcs = conn.get_all_vpcs()
all_vpcs.should.have.length_of(1)
all_vpcs.should.have.length_of(2)
vpc.delete()
all_vpcs = conn.get_all_vpcs()
all_vpcs.should.have.length_of(0)
all_vpcs.should.have.length_of(1)
with assert_raises(EC2ResponseError) as cm:
conn.delete_vpc("vpc-1234abcd")
@ -40,14 +40,14 @@ def test_vpc_defaults():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
conn.get_all_vpcs().should.have.length_of(1)
conn.get_all_route_tables().should.have.length_of(1)
conn.get_all_vpcs().should.have.length_of(2)
conn.get_all_route_tables().should.have.length_of(2)
conn.get_all_security_groups(filters={'vpc-id': [vpc.id]}).should.have.length_of(1)
vpc.delete()
conn.get_all_vpcs().should.have.length_of(0)
conn.get_all_route_tables().should.have.length_of(0)
conn.get_all_vpcs().should.have.length_of(1)
conn.get_all_route_tables().should.have.length_of(1)
conn.get_all_security_groups(filters={'vpc-id': [vpc.id]}).should.have.length_of(0)
@mock_ec2
@ -56,7 +56,7 @@ def test_vpc_isdefault_filter():
vpc = conn.create_vpc("10.0.0.0/16")
conn.get_all_vpcs(filters={'isDefault': 'true'}).should.have.length_of(1)
vpc.delete()
conn.get_all_vpcs(filters={'isDefault': 'true'}).should.have.length_of(0)
conn.get_all_vpcs(filters={'isDefault': 'true'}).should.have.length_of(1)
@mock_ec2
@ -65,10 +65,10 @@ def test_multiple_vpcs_default_filter():
conn.create_vpc("10.8.0.0/16")
conn.create_vpc("10.0.0.0/16")
conn.create_vpc("192.168.0.0/16")
conn.get_all_vpcs().should.have.length_of(3)
conn.get_all_vpcs().should.have.length_of(4)
vpc = conn.get_all_vpcs(filters={'isDefault': 'true'})
vpc.should.have.length_of(1)
vpc[0].cidr_block.should.equal('10.8.0.0/16')
vpc[0].cidr_block.should.equal('172.31.0.0/16')
@mock_ec2
@ -76,9 +76,9 @@ def test_vpc_state_available_filter():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
conn.create_vpc("10.1.0.0/16")
conn.get_all_vpcs(filters={'state': 'available'}).should.have.length_of(2)
conn.get_all_vpcs(filters={'state': 'available'}).should.have.length_of(3)
vpc.delete()
conn.get_all_vpcs(filters={'state': 'available'}).should.have.length_of(1)
conn.get_all_vpcs(filters={'state': 'available'}).should.have.length_of(2)
@mock_ec2
def test_vpc_tagging():
@ -86,13 +86,12 @@ def test_vpc_tagging():
vpc = conn.create_vpc("10.0.0.0/16")
vpc.add_tag("a key", "some value")
tag = conn.get_all_tags()[0]
tag.name.should.equal("a key")
tag.value.should.equal("some value")
# Refresh the vpc
vpc = conn.get_all_vpcs()[0]
vpc = conn.get_all_vpcs(vpc_ids=[vpc.id])[0]
vpc.tags.should.have.length_of(1)
vpc.tags["a key"].should.equal("some value")
@ -245,7 +244,8 @@ def test_default_vpc():
ec2 = boto3.resource('ec2', region_name='us-west-1')
# Create the default VPC
default_vpc = ec2.create_vpc(CidrBlock='172.31.0.0/16')
default_vpc = list(ec2.vpcs.all())[0]
default_vpc.cidr_block.should.equal('172.31.0.0/16')
default_vpc.reload()
default_vpc.is_default.should.be.ok