diff --git a/plugins/modules/ec2_vpc_route_table.py b/plugins/modules/ec2_vpc_route_table.py index 19fa11ef041..be7dfe5c352 100644 --- a/plugins/modules/ec2_vpc_route_table.py +++ b/plugins/modules/ec2_vpc_route_table.py @@ -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: @@ -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: @@ -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: