def gateway_in_subnet_exists(client, subnet_id, allocation_id=None, check_mode=False):
 allocation_id_exists = False
 gateways = []
 states = ['available', 'pending']
 (gws_retrieved, _, gws) = get_nat_gateways(client, subnet_id, states=states, check_mode=check_mode)
 if (not gws_retrieved):
  return (gateways, allocation_id_exists)
 for gw in gws:
  for address in gw['nat_gateway_addresses']:
   if allocation_id:
    if (address.get('allocation_id') == allocation_id):
     allocation_id_exists = True
     gateways.append(gw)
   else:
    gateways.append(gw)
 return (gateways, allocation_id_exists)

def gateway_in_subnet_exists ( client , subnet_id , allocation_id = None , check_mode = False ) : allocation_id_exists = False gateways = [ ] states = [ 'available' , 'pending' ] ( gws_retrieved , _ , gws ) = get_nat_gateways ( client , subnet_id , states = states , check_mode = check_mode ) if ( not gws_retrieved ) : return ( gateways , allocation_id_exists ) for gw in gws : for address in gw [ 'nat_gateway_addresses' ] : if allocation_id : if ( address . get ( 'allocation_id' ) == allocation_id ) : allocation_id_exists = True gateways . append ( gw ) else : gateways . append ( gw ) return ( gateways , allocation_id_exists )
retrieve all nat gateways for a subnet .