def subnet_group_present(name, description, subnet_ids=None, subnet_names=None, tags=None, region=None, key=None, keyid=None, profile=None):
 if (not salt.utils.exactly_one((subnet_ids, subnet_names))):
  raise SaltInvocationError('One (but not both) of subnet_ids or subnet_names must be provided.')
 ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
 if (not subnet_ids):
  subnet_ids = []
 if subnet_names:
  for i in subnet_names:
   r = __salt__['boto_vpc.get_resource_id']('subnet', name=i, region=region, key=key, keyid=keyid, profile=profile)
   if ('error' in r):
    ret['comment'] = 'Error looking up subnet ids: {0}'.format(r['error']['message'])
    ret['result'] = False
    return ret
   if (r['id'] is None):
    ret['comment'] = 'Subnet {0} does not exist.'.format(i)
    ret['result'] = False
    return ret
   subnet_ids.append(r['id'])
 exists = __salt__['boto_rds.subnet_group_exists'](name=name, tags=tags, region=region, key=key, keyid=keyid, profile=profile)
 if (not exists):
  if __opts__['test']:
   ret['comment'] = 'Subnet group {0} is set to be created.'.format(name)
   ret['result'] = None
   return ret
  if (not r.get('created')):
   ret['result'] = False
   ret['comment'] = 'Failed to create {0} subnet group.'.format(r['error']['message'])
   return ret
  created = __salt__['boto_rds.create_subnet_group'](name=name, description=description, subnet_ids=subnet_ids, tags=tags, region=region, key=key, keyid=keyid, profile=profile)
  if (not created):
   ret['result'] = False
   ret['comment'] = 'Failed to create {0} subnet group.'.format(name)
   return ret
  ret['changes']['old'] = None
  ret['changes']['new'] = name
  ret['comment'] = 'Subnet {0} created.'.format(name)
 else:
  ret['comment'] = 'Subnet {0} present.'.format(name)
  return ret

def subnet_group_present ( name , description , subnet_ids = None , subnet_names = None , tags = None , region = None , key = None , keyid = None , profile = None ) : if ( not salt . utils . exactly_one ( ( subnet_ids , subnet_names ) ) ) : raise SaltInvocationError ( 'One (but not both) of subnet_ids or subnet_names must be provided.' ) ret = { 'name' : name , 'result' : True , 'comment' : '' , 'changes' : { } } if ( not subnet_ids ) : subnet_ids = [ ] if subnet_names : for i in subnet_names : r = __salt__ [ 'boto_vpc.get_resource_id' ] ( 'subnet' , name = i , region = region , key = key , keyid = keyid , profile = profile ) if ( 'error' in r ) : ret [ 'comment' ] = 'Error looking up subnet ids: {0}' . format ( r [ 'error' ] [ 'message' ] ) ret [ 'result' ] = False return ret if ( r [ 'id' ] is None ) : ret [ 'comment' ] = 'Subnet {0} does not exist.' . format ( i ) ret [ 'result' ] = False return ret subnet_ids . append ( r [ 'id' ] ) exists = __salt__ [ 'boto_rds.subnet_group_exists' ] ( name = name , tags = tags , region = region , key = key , keyid = keyid , profile = profile ) if ( not exists ) : if __opts__ [ 'test' ] : ret [ 'comment' ] = 'Subnet group {0} is set to be created.' . format ( name ) ret [ 'result' ] = None return ret if ( not r . get ( 'created' ) ) : ret [ 'result' ] = False ret [ 'comment' ] = 'Failed to create {0} subnet group.' . format ( r [ 'error' ] [ 'message' ] ) return ret created = __salt__ [ 'boto_rds.create_subnet_group' ] ( name = name , description = description , subnet_ids = subnet_ids , tags = tags , region = region , key = key , keyid = keyid , profile = profile ) if ( not created ) : ret [ 'result' ] = False ret [ 'comment' ] = 'Failed to create {0} subnet group.' . format ( name ) return ret ret [ 'changes' ] [ 'old' ] = None ret [ 'changes' ] [ 'new' ] = name ret [ 'comment' ] = 'Subnet {0} created.' . format ( name ) else : ret [ 'comment' ] = 'Subnet {0} present.' . format ( name ) return ret
ensure elasticache subnet group exists .