EC2: create_route() should allow overlapping CIDR's (#6106)
This commit is contained in:
parent
681db433fd
commit
53603b01c7
@ -514,7 +514,7 @@ class RouteBackend:
|
|||||||
for route in route_table.routes.values():
|
for route in route_table.routes.values():
|
||||||
if not route.destination_cidr_block:
|
if not route.destination_cidr_block:
|
||||||
continue
|
continue
|
||||||
if not route.local and ip_v4_network.overlaps(
|
if not route.local and ip_v4_network == ipaddress.IPv4Network(
|
||||||
ipaddress.IPv4Network(str(route.destination_cidr_block))
|
str(route.destination_cidr_block)
|
||||||
):
|
):
|
||||||
raise RouteAlreadyExistsError(destination_cidr_block)
|
raise RouteAlreadyExistsError(destination_cidr_block)
|
||||||
|
@ -664,16 +664,18 @@ def test_routes_already_exist():
|
|||||||
ex.value.response["ResponseMetadata"].should.have.key("RequestId")
|
ex.value.response["ResponseMetadata"].should.have.key("RequestId")
|
||||||
ex.value.response["Error"]["Code"].should.equal("RouteAlreadyExists")
|
ex.value.response["Error"]["Code"].should.equal("RouteAlreadyExists")
|
||||||
|
|
||||||
with pytest.raises(ClientError) as ex:
|
# We can create a sub cidr
|
||||||
client.create_route(
|
client.create_route(
|
||||||
RouteTableId=main_route_table.id,
|
RouteTableId=main_route_table.id,
|
||||||
DestinationCidrBlock=ROUTE_SUB_CIDR,
|
DestinationCidrBlock=ROUTE_SUB_CIDR,
|
||||||
GatewayId=igw.id,
|
GatewayId=igw.id,
|
||||||
)
|
)
|
||||||
|
# Or even a catch-all
|
||||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
client.create_route(
|
||||||
ex.value.response["ResponseMetadata"].should.have.key("RequestId")
|
RouteTableId=main_route_table.id,
|
||||||
ex.value.response["Error"]["Code"].should.equal("RouteAlreadyExists")
|
DestinationCidrBlock="0.0.0.0/0",
|
||||||
|
GatewayId=igw.id,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user