def get_nat_gateways(client, subnet_id=None, nat_gateway_id=None, states=None, check_mode=False):
 params = dict()
 err_msg = ''
 gateways_retrieved = False
 existing_gateways = list()
 if (not states):
  states = ['available', 'pending']
 if nat_gateway_id:
  params['NatGatewayIds'] = [nat_gateway_id]
 else:
  params['Filter'] = [{'Name': 'subnet-id', 'Values': [subnet_id]}, {'Name': 'state', 'Values': states}]
 try:
  if (not check_mode):
   gateways = client.describe_nat_gateways(**params)['NatGateways']
   if gateways:
    for gw in gateways:
     existing_gateways.append(convert_to_lower(gw))
   gateways_retrieved = True
  else:
   gateways_retrieved = True
   if nat_gateway_id:
    if (DRY_RUN_GATEWAYS[0]['nat_gateway_id'] == nat_gateway_id):
     existing_gateways = DRY_RUN_GATEWAYS
   elif subnet_id:
    if (DRY_RUN_GATEWAYS[0]['subnet_id'] == subnet_id):
     existing_gateways = DRY_RUN_GATEWAYS
   err_msg = '{0} Retrieving gateways'.format(DRY_RUN_MSGS)
 except botocore.exceptions.ClientError as e:
  err_msg = str(e)
 return (gateways_retrieved, err_msg, existing_gateways)

def get_nat_gateways ( client , subnet_id = None , nat_gateway_id = None , states = None , check_mode = False ) : params = dict ( ) err_msg = '' gateways_retrieved = False existing_gateways = list ( ) if ( not states ) : states = [ 'available' , 'pending' ] if nat_gateway_id : params [ 'NatGatewayIds' ] = [ nat_gateway_id ] else : params [ 'Filter' ] = [ { 'Name' : 'subnet-id' , 'Values' : [ subnet_id ] } , { 'Name' : 'state' , 'Values' : states } ] try : if ( not check_mode ) : gateways = client . describe_nat_gateways ( ** params ) [ 'NatGateways' ] if gateways : for gw in gateways : existing_gateways . append ( convert_to_lower ( gw ) ) gateways_retrieved = True else : gateways_retrieved = True if nat_gateway_id : if ( DRY_RUN_GATEWAYS [ 0 ] [ 'nat_gateway_id' ] == nat_gateway_id ) : existing_gateways = DRY_RUN_GATEWAYS elif subnet_id : if ( DRY_RUN_GATEWAYS [ 0 ] [ 'subnet_id' ] == subnet_id ) : existing_gateways = DRY_RUN_GATEWAYS err_msg = '{0} Retrieving gateways' . format ( DRY_RUN_MSGS ) except botocore . exceptions . ClientError as e : err_msg = str ( e ) return ( gateways_retrieved , err_msg , existing_gateways )
retrieve a list of nat gateways args: client : boto3 client kwargs: subnet_id : the subnet_id the nat resides in .