From d48cd31ebb234159285e64e7dc9cbf55b8390830 Mon Sep 17 00:00:00 2001 From: Macwan Nevil Date: Sun, 12 Sep 2021 13:15:38 +0530 Subject: [PATCH] support for carrier gateway in rt (#4282) --- moto/ec2/models.py | 7 +++++++ moto/ec2/responses/route_tables.py | 7 +++++++ tests/terraform-tests.success.txt | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 65d89a2bd..d4ab7f931 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -4836,6 +4836,7 @@ class Route(CloudFormationModel): transit_gateway=None, interface=None, vpc_pcx=None, + carrier_gateway=None, ): self.id = generate_route_id( route_table.id, destination_cidr_block, destination_ipv6_cidr_block @@ -4852,6 +4853,7 @@ class Route(CloudFormationModel): self.transit_gateway = transit_gateway self.interface = interface self.vpc_pcx = vpc_pcx + self.carrier_gateway = carrier_gateway @property def physical_resource_id(self): @@ -5124,6 +5126,7 @@ class RouteBackend(object): transit_gateway_id=None, interface_id=None, vpc_peering_connection_id=None, + carrier_gateway_id=None, ): gateway = None nat_gateway = None @@ -5131,6 +5134,7 @@ class RouteBackend(object): egress_only_igw = None interface = None prefix_list = None + carrier_gateway = None route_table = self.get_route_table(route_table_id) @@ -5159,6 +5163,8 @@ class RouteBackend(object): transit_gateway = self.transit_gateways.get(transit_gateway_id) if destination_prefix_list_id is not None: prefix_list = self.managed_prefix_lists.get(destination_prefix_list_id) + if carrier_gateway_id is not None: + carrier_gateway = self.carrier_gateways.get(carrier_gateway_id) route = Route( route_table, @@ -5172,6 +5178,7 @@ class RouteBackend(object): egress_only_igw=egress_only_igw, transit_gateway=transit_gateway, interface=interface, + carrier_gateway=carrier_gateway, vpc_pcx=self.get_vpc_peering_connection(vpc_peering_connection_id) if vpc_peering_connection_id else None, diff --git a/moto/ec2/responses/route_tables.py b/moto/ec2/responses/route_tables.py index 3f4fc6716..3409320b9 100644 --- a/moto/ec2/responses/route_tables.py +++ b/moto/ec2/responses/route_tables.py @@ -26,6 +26,7 @@ class RouteTables(BaseResponse): transit_gateway_id = self._get_param("TransitGatewayId") interface_id = self._get_param("NetworkInterfaceId") pcx_id = self._get_param("VpcPeeringConnectionId") + carrier_gateway_id = self._get_param("CarrierGatewayId") self.ec2_backend.create_route( route_table_id, @@ -39,6 +40,7 @@ class RouteTables(BaseResponse): transit_gateway_id=transit_gateway_id, interface_id=interface_id, vpc_peering_connection_id=pcx_id, + carrier_gateway_id=carrier_gateway_id, ) template = self.response_template(CREATE_ROUTE_RESPONSE) @@ -215,6 +217,11 @@ DESCRIBE_ROUTE_TABLES_RESPONSE = """ CreateRoute blackhole {% endif %} + {% if route.carrier_gateway %} + {{ route.carrier_gateway.id }} + CreateRoute + blackhole + {% endif %} {% if route.nat_gateway %} {{ route.nat_gateway.id }} active diff --git a/tests/terraform-tests.success.txt b/tests/terraform-tests.success.txt index 18080f276..79521adf0 100644 --- a/tests/terraform-tests.success.txt +++ b/tests/terraform-tests.success.txt @@ -99,7 +99,6 @@ TestAccAWSAPIGatewayStage_accessLogSettings_kinesis TestAccAWSAPIGatewayStage_accessLogSettings TestAccAWSRouteTable_ConditionalCidrBlock TestAccAWSRouteTable_IPv4_To_Instance -TestAccAWSRouteTable_RequireRouteTarget TestAccAWSRouteTable_Route_ConfigMode TestAccAWSRouteTable_tags TestAccAWSRouteTable_vgwRoutePropagation @@ -115,6 +114,7 @@ TestAccAWSRouteTable_basic TestAccAWSRouteTable_MultipleRoutes TestAccAWSRouteTable_PrefixList_To_InternetGateway TestAccAWSRouteTable_VpcMultipleCidrs +TestAccAWSRouteTable_IPv4_To_CarrierGateway TestAccAWSSsmDocumentDataSource TestAccAwsEc2ManagedPrefixList TestAccAWSEgressOnlyInternetGateway