EC2: DestinationCidrBlock filter for DescribeRouteTables (#5932)

This commit is contained in:
Viren Nadkarni 2023-03-06 18:49:23 +05:30 committed by GitHub
parent 072347ea96
commit a30dbafc93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -95,6 +95,12 @@ class RouteTable(TaggedEC2Resource, CloudFormationModel):
return self.all_associations_ids
elif filter_name == "association.subnet-id":
return self.associations.values()
elif filter_name == "route.destination-cidr-block":
return [
route.destination_cidr_block
for route in self.routes.values()
if route.destination_cidr_block is not None
]
elif filter_name == "route.gateway-id":
return [
route.gateway.id

View File

@ -147,6 +147,21 @@ def test_route_tables_filters_standard():
[route["GatewayId"] == igw.id for table in resp for route in table["Routes"]]
)
# Filter by route destination CIDR block
resp = client.describe_route_tables(
Filters=[
{"Name": "route.destination-cidr-block", "Values": ["10.0.0.4/24"]},
]
)["RouteTables"]
assert any([route_table["RouteTableId"] == route_table2.id for route_table in resp])
assert any(
[
route["DestinationCidrBlock"] == "10.0.0.4/24"
for table in resp
for route in table["Routes"]
]
)
# Unsupported filter
if not settings.TEST_SERVER_MODE:
# ServerMode will just throw a generic 500