fix route table association by internet gateway (#3773)
* fix route table association by internet gateway per https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AssociateRouteTable.html * Route53 - Add test for route table association by internet gateway - Minor test tweak for Main route table values TODO: explicitly set the route table main route association * Route53 - forgot subnet id association test Co-authored-by: Tony Greising-Murschel <tony@platform.sh>
This commit is contained in:
parent
1b288b6936
commit
5fe3a707ed
3 changed files with 52 additions and 10 deletions
|
|
@ -4179,7 +4179,7 @@ class RouteTableBackend(object):
|
|||
self.route_tables.pop(route_table_id)
|
||||
return True
|
||||
|
||||
def associate_route_table(self, route_table_id, subnet_id):
|
||||
def associate_route_table(self, route_table_id, gateway_id=None, subnet_id=None):
|
||||
# Idempotent if association already exists.
|
||||
route_tables_by_subnet = self.get_all_route_tables(
|
||||
filters={"association.subnet-id": [subnet_id]}
|
||||
|
|
@ -4193,10 +4193,15 @@ class RouteTableBackend(object):
|
|||
|
||||
# Association does not yet exist, so create it.
|
||||
route_table = self.get_route_table(route_table_id)
|
||||
self.get_subnet(subnet_id) # Validate subnet exists
|
||||
association_id = random_subnet_association_id()
|
||||
route_table.associations[association_id] = subnet_id
|
||||
return association_id
|
||||
if gateway_id is None:
|
||||
self.get_subnet(subnet_id) # Validate subnet exists
|
||||
association_id = random_subnet_association_id()
|
||||
route_table.associations[association_id] = subnet_id
|
||||
return association_id
|
||||
if subnet_id is None:
|
||||
association_id = random_subnet_association_id()
|
||||
route_table.associations[association_id] = gateway_id
|
||||
return association_id
|
||||
|
||||
def disassociate_route_table(self, association_id):
|
||||
for route_table in self.route_tables.values():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue