Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jatorcasso committed Mar 9, 2022
1 parent f429347 commit f76b4ef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/modules/ec2_vpc_route_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
gateway_id:
description:
- The ID of the gateway to associate with the route table.
- If I(gateway_id) is 'None' or '', gateway will be disassociated with the route table.
- If I(gateway_id) is C('None') or C(''), gateway will be disassociated with the route table.
type: str
version_added: 3.2.0
lookup:
Expand Down Expand Up @@ -576,7 +576,8 @@ def disassociate_gateway(connection, module, route_table):
# Subnet associations are handled in its method
changed = False
associations_to_delete = [association['RouteTableAssociationId'] for association in route_table['Associations'] if not association['Main']
and association.get('GatewayId') and association['AssociationState']['State'] == 'associated']
and association.get('GatewayId')
and (association['AssociationState']['State'] == 'associated' or association['AssociationState']['State'] == 'associating')]
for association_id in associations_to_delete:
changed = True
if not module.check_mode:
Expand All @@ -599,7 +600,8 @@ def associate_gateway(connection, module, route_table, gateway_id):
for association in table.get('Associations'):
if association['Main']:
continue
if association.get('GatewayId') and association['GatewayId'] == gateway_id and association['AssociationState']['State'] == 'associated':
if association.get('GatewayId') and association['GatewayId'] == gateway_id and (association['AssociationState']['State'] == 'associated'
or association['AssociationState']['State'] == 'associating'):
if table['RouteTableId'] == route_table['RouteTableId']:
return False
elif module.check_mode:
Expand Down

0 comments on commit f76b4ef

Please sign in to comment.