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():
|
||||
if not route.destination_cidr_block:
|
||||
continue
|
||||
if not route.local and ip_v4_network.overlaps(
|
||||
ipaddress.IPv4Network(str(route.destination_cidr_block))
|
||||
if not route.local and ip_v4_network == ipaddress.IPv4Network(
|
||||
str(route.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["Error"]["Code"].should.equal("RouteAlreadyExists")
|
||||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
# We can create a sub cidr
|
||||
client.create_route(
|
||||
RouteTableId=main_route_table.id,
|
||||
DestinationCidrBlock=ROUTE_SUB_CIDR,
|
||||
GatewayId=igw.id,
|
||||
)
|
||||
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["ResponseMetadata"].should.have.key("RequestId")
|
||||
ex.value.response["Error"]["Code"].should.equal("RouteAlreadyExists")
|
||||
# Or even a catch-all
|
||||
client.create_route(
|
||||
RouteTableId=main_route_table.id,
|
||||
DestinationCidrBlock="0.0.0.0/0",
|
||||
GatewayId=igw.id,
|
||||
)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
Loading…
x
Reference in New Issue
Block a user