fixed owner id and delete rt (#4161)

This commit is contained in:
Macwan Nevil 2021-08-12 01:53:04 +05:30 committed by GitHub
parent 574053cb27
commit f2b8318211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 6 deletions

View File

@ -4375,6 +4375,10 @@ class VPCEndPoint(TaggedEC2Resource):
self.dns_entries = dns_entries
self.add_tags(tags or {})
@property
def owner_id(self):
return ACCOUNT_ID
@property
def created_at(self):
return iso_8601_datetime_with_milliseconds(self._created_at)
@ -4476,12 +4480,17 @@ class RouteBackend(object):
route_table = self.get_route_table(route_table_id)
return route_table.get(route_id)
def delete_route(self, route_table_id, destination_cidr_block):
def delete_route(
self, route_table_id, destination_cidr_block, destination_ipv6_cidr_block=None
):
cidr = destination_cidr_block
route_table = self.get_route_table(route_table_id)
route_id = generate_route_id(route_table_id, destination_cidr_block)
if destination_ipv6_cidr_block:
cidr = destination_ipv6_cidr_block
route_id = generate_route_id(route_table_id, cidr)
deleted = route_table.routes.pop(route_id, None)
if not deleted:
raise InvalidRouteError(route_table_id, destination_cidr_block)
raise InvalidRouteError(route_table_id, cidr)
return deleted

View File

@ -50,7 +50,10 @@ class RouteTables(BaseResponse):
def delete_route(self):
route_table_id = self._get_param("RouteTableId")
destination_cidr_block = self._get_param("DestinationCidrBlock")
self.ec2_backend.delete_route(route_table_id, destination_cidr_block)
destination_ipv6_cidr_block = self._get_param("DestinationIpv6CidrBlock")
self.ec2_backend.delete_route(
route_table_id, destination_cidr_block, destination_ipv6_cidr_block
)
template = self.response_template(DELETE_ROUTE_RESPONSE)
return template.render()
@ -128,7 +131,11 @@ CREATE_ROUTE_TABLE_RESPONSE = """
{% for route in route_table.routes.values() %}
{% if route.local %}
<item>
<destinationCidrBlock>{{ route.destination_cidr_block }}</destinationCidrBlock>
{% if route.destination_ipv6_cidr_block %}
<destinationIpv6CidrBlock>{{ route.destination_ipv6_cidr_block }}</destinationIpv6CidrBlock>
{% else %}
<destinationCidrBlock>{{ route.destination_cidr_block }}</destinationCidrBlock>
{% endif %}
<gatewayId>local</gatewayId>
<state>active</state>
</item>
@ -158,10 +165,15 @@ DESCRIBE_ROUTE_TABLES_RESPONSE = """
<item>
<routeTableId>{{ route_table.id }}</routeTableId>
<vpcId>{{ route_table.vpc_id }}</vpcId>
<routeSet>
<ownerId>{{ route_table.owner_id }}</ownerId>
<routeSet>
{% for route in route_table.routes.values() %}
<item>
{% if route.destination_ipv6_cidr_block %}
<destinationIpv6CidrBlock>{{ route.destination_ipv6_cidr_block }}</destinationIpv6CidrBlock>
{% else %}
<destinationCidrBlock>{{ route.destination_cidr_block }}</destinationCidrBlock>
{% endif %}
{% if route.local %}
<gatewayId>local</gatewayId>
<origin>CreateRouteTable</origin>

View File

@ -73,3 +73,11 @@ TestAccAWSUserPolicyAttachment
TestAccAWSUserSSHKey
TestAccAWSVpc_
TestAccAWSRouteTable_disappears
TestAccAWSRouteTable_RequireRouteTarget
TestAccAWSRouteTable_Route_ConfigMode
TestAccAWSRouteTable_tags
TestAccAWSRouteTable_vgwRoutePropagation
TestAccAWSRouteTable_RequireRouteTarget
TestAccAWSRouteTable_disappears_SubnetAssociation
TestAccAWSRouteTable_disappears
TestAccAWSRouteTable_basic

View File

@ -588,6 +588,7 @@ def test_create_route_with_invalid_destination_cidr_block_parameter():
route
for route in route_table.routes
if route.destination_cidr_block != vpc.cidr_block
or route.destination_ipv6_cidr_block != vpc.cidr_block
]
new_routes.should.have.length_of(1)
new_routes[0].route_table_id.shouldnt.be.equal(None)