diff --git a/moto/ec2/models/availability_zones_and_regions.py b/moto/ec2/models/availability_zones_and_regions.py index 342d87c2c..7ed9ce7fc 100644 --- a/moto/ec2/models/availability_zones_and_regions.py +++ b/moto/ec2/models/availability_zones_and_regions.py @@ -1,4 +1,5 @@ from boto3 import Session +from moto.utilities.utils import filter_resources class Region(object): @@ -9,10 +10,11 @@ class Region(object): class Zone(object): - def __init__(self, name, region_name, zone_id): + def __init__(self, name, region_name, zone_id, zone_type="availability-zone"): self.name = name self.region_name = region_name self.zone_id = zone_id + self.zone_type = zone_type class RegionsAndZonesBackend: @@ -304,9 +306,19 @@ class RegionsAndZonesBackend: ret.append(region) return ret - def describe_availability_zones(self): + def describe_availability_zones(self, filters=None): # We might not have any zones for the current region, if it was introduced recently - return self.zones.get(self.region_name, []) + zones = self.zones.get(self.region_name, []) + attr_pairs = ( + ("zone-id", "zone_id"), + ("zone-type", "zone_type"), + ("zone-name", "name"), + ("region-name", "region_name"), + ) + result = zones + if filters: + result = filter_resources(zones, filters, attr_pairs) + return result def get_zone_by_name(self, name): for zone in self.describe_availability_zones(): diff --git a/moto/ec2/models/vpcs.py b/moto/ec2/models/vpcs.py index d7b374e8d..239eb9446 100644 --- a/moto/ec2/models/vpcs.py +++ b/moto/ec2/models/vpcs.py @@ -139,6 +139,7 @@ class VPC(TaggedEC2Resource, CloudFormationModel): is_default, instance_tenancy="default", amazon_provided_ipv6_cidr_block=False, + ipv6_cidr_block_network_border_group=None, ): self.ec2_backend = ec2_backend @@ -161,6 +162,7 @@ class VPC(TaggedEC2Resource, CloudFormationModel): self.associate_vpc_cidr_block( cidr_block, amazon_provided_ipv6_cidr_block=amazon_provided_ipv6_cidr_block, + ipv6_cidr_block_network_border_group=ipv6_cidr_block_network_border_group, ) @property @@ -246,7 +248,10 @@ class VPC(TaggedEC2Resource, CloudFormationModel): return True def associate_vpc_cidr_block( - self, cidr_block, amazon_provided_ipv6_cidr_block=False + self, + cidr_block, + amazon_provided_ipv6_cidr_block=False, + ipv6_cidr_block_network_border_group=None, ): max_associations = 5 if not amazon_provided_ipv6_cidr_block else 1 @@ -274,6 +279,11 @@ class VPC(TaggedEC2Resource, CloudFormationModel): association_set["cidr_block"] = ( random_ipv6_cidr() if amazon_provided_ipv6_cidr_block else cidr_block ) + if amazon_provided_ipv6_cidr_block: + association_set["ipv6_pool"] = "Amazon" + association_set[ + "ipv6_cidr_block_network_border_group" + ] = ipv6_cidr_block_network_border_group self.cidr_block_association_set[association_id] = association_set return association_set @@ -345,6 +355,7 @@ class VPCBackend: cidr_block, instance_tenancy="default", amazon_provided_ipv6_cidr_block=False, + ipv6_cidr_block_network_border_group=None, tags=None, is_default=False, ): @@ -362,6 +373,7 @@ class VPCBackend: is_default=is_default, instance_tenancy=instance_tenancy, amazon_provided_ipv6_cidr_block=amazon_provided_ipv6_cidr_block, + ipv6_cidr_block_network_border_group=ipv6_cidr_block_network_border_group, ) for tag in tags or []: diff --git a/moto/ec2/responses/availability_zones_and_regions.py b/moto/ec2/responses/availability_zones_and_regions.py index 3345dea62..c8a03bb9f 100644 --- a/moto/ec2/responses/availability_zones_and_regions.py +++ b/moto/ec2/responses/availability_zones_and_regions.py @@ -4,7 +4,8 @@ from moto.core.responses import BaseResponse class AvailabilityZonesAndRegions(BaseResponse): def describe_availability_zones(self): self.error_on_dryrun() - zones = self.ec2_backend.describe_availability_zones() + filters = self._filters_from_querystring() + zones = self.ec2_backend.describe_availability_zones(filters) template = self.response_template(DESCRIBE_ZONES_RESPONSE) return template.render(zones=zones) @@ -38,6 +39,7 @@ DESCRIBE_ZONES_RESPONSE = """ {{assoc.cidr_block_state.state}} + {{ assoc.ipv6_cidr_block_network_border_group }} + {{ assoc.ipv6_pool }} {% endfor %} diff --git a/tests/terraformtests/etc/0002-EC2-reduce-wait-times.patch b/tests/terraformtests/etc/0002-EC2-reduce-wait-times.patch index 3f6a09e64..87c1a4ff8 100644 --- a/tests/terraformtests/etc/0002-EC2-reduce-wait-times.patch +++ b/tests/terraformtests/etc/0002-EC2-reduce-wait-times.patch @@ -281,7 +281,7 @@ index d42232fc09..8f7f983957 100644 ) -const EventualConsistencyTimeout = 5 * time.Minute -+const EventualConsistencyTimeout = 1 * time.Minute ++const EventualConsistencyTimeout = 5 * time.Second // CreateTags creates {{ .ServicePackage }} service tags for new resources. // The identifier is typically the Amazon Resource Name (ARN), although @@ -1021,8 +1021,8 @@ index 5ad62e86c0..68209e7fb8 100644 const ( - vpcIPv6CIDRBlockAssociationCreatedTimeout = 10 * time.Minute - vpcIPv6CIDRBlockAssociationDeletedTimeout = 5 * time.Minute -+ vpcIPv6CIDRBlockAssociationCreatedTimeout = 10 * time.Second -+ vpcIPv6CIDRBlockAssociationDeletedTimeout = 5 * time.Second ++ vpcIPv6CIDRBlockAssociationCreatedTimeout = 15 * time.Second ++ vpcIPv6CIDRBlockAssociationDeletedTimeout = 15 * time.Second ) func WaitVPCIPv6CIDRBlockAssociationCreated(conn *ec2.EC2, id string, timeout time.Duration) (*ec2.VpcCidrBlockState, error) { diff --git a/tests/terraformtests/terraform-tests.success.txt b/tests/terraformtests/terraform-tests.success.txt index 30b0ba3ae..35894571b 100644 --- a/tests/terraformtests/terraform-tests.success.txt +++ b/tests/terraformtests/terraform-tests.success.txt @@ -56,6 +56,7 @@ ec2: - TestAccEC2VPCsDataSource - TestAccEC2VPNGateway_ - TestAccEC2VPNGatewayAttachment_ + - TestAccVPC_ ecr: - TestAccECRLifecyclePolicy - TestAccECRRegistryPolicy