EC2: DestinationCidrBlock filter for DescribeRouteTables (#5932)
This commit is contained in:
parent
072347ea96
commit
a30dbafc93
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user