def nat_gateway_present(name, subnet_name=None, subnet_id=None, region=None, key=None, keyid=None, profile=None):
 ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
 r = __salt__['boto_vpc.describe_nat_gateways'](subnet_name=subnet_name, subnet_id=subnet_id, region=region, key=key, keyid=keyid, profile=profile)
 if (not r):
  if __opts__['test']:
   msg = 'Nat gateway is set to be created.'
   ret['comment'] = msg
   ret['result'] = None
   return ret
  r = __salt__['boto_vpc.create_nat_gateway'](subnet_name=subnet_name, subnet_id=subnet_id, region=region, key=key, keyid=keyid, profile=profile)
  if (not r.get('created')):
   ret['result'] = False
   ret['comment'] = 'Failed to create nat gateway: {0}.'.format(r['error']['message'])
   return ret
  ret['changes']['old'] = {'nat_gateway': None}
  ret['changes']['new'] = {'nat_gateway': r['id']}
  ret['comment'] = 'Nat gateway created.'
  return ret
 inst = r[0]
 _id = inst.get('NatGatewayId')
 ret['comment'] = 'Nat gateway {0} present.'.format(_id)
 return ret

def nat_gateway_present ( name , subnet_name = None , subnet_id = None , region = None , key = None , keyid = None , profile = None ) : ret = { 'name' : name , 'result' : True , 'comment' : '' , 'changes' : { } } r = __salt__ [ 'boto_vpc.describe_nat_gateways' ] ( subnet_name = subnet_name , subnet_id = subnet_id , region = region , key = key , keyid = keyid , profile = profile ) if ( not r ) : if __opts__ [ 'test' ] : msg = 'Nat gateway is set to be created.' ret [ 'comment' ] = msg ret [ 'result' ] = None return ret r = __salt__ [ 'boto_vpc.create_nat_gateway' ] ( subnet_name = subnet_name , subnet_id = subnet_id , region = region , key = key , keyid = keyid , profile = profile ) if ( not r . get ( 'created' ) ) : ret [ 'result' ] = False ret [ 'comment' ] = 'Failed to create nat gateway: {0}.' . format ( r [ 'error' ] [ 'message' ] ) return ret ret [ 'changes' ] [ 'old' ] = { 'nat_gateway' : None } ret [ 'changes' ] [ 'new' ] = { 'nat_gateway' : r [ 'id' ] } ret [ 'comment' ] = 'Nat gateway created.' return ret inst = r [ 0 ] _id = inst . get ( 'NatGatewayId' ) ret [ 'comment' ] = 'Nat gateway {0} present.' . format ( _id ) return ret
ensure a nat gateway exists within the specified subnet this function requires boto3 .