Create an ElastiCache subnet group

    Example:

    .. code-block:: bash

        salt myminion boto3_elasticache.create_cache_subnet_group name=my-subnet-group \
                                              CacheSubnetGroupDescription="description" \
                                              subnets='[myVPCSubnet1,myVPCSubnet2]'

def create_cache_subnet_group(name, subnets=None, region=None, key=None, keyid=None, profile=None, **args):
    '''
    Create an ElastiCache subnet group

    Example:

    .. code-block:: bash

        salt myminion boto3_elasticache.create_cache_subnet_group name=my-subnet-group \
                                              CacheSubnetGroupDescription="description" \
                                              subnets='[myVPCSubnet1,myVPCSubnet2]'
    '''
    if subnets:
        if 'SubnetIds' not in args:
            args['SubnetIds'] = []
        if not isinstance(subnets, list):
            subnets = [subnets]
        for subnet in subnets:
            if subnet.startswith('subnet-'):
                # Moderately safe assumption... :)  Will be caught further down if incorrect.
                args['SubnetIds'] += [subnet]
                continue
            sn = __salt__['boto_vpc.describe_subnets'](subnet_names=subnet, region=region, key=key,
                                                       keyid=keyid, profile=profile).get('subnets')
            if not sn:
                raise SaltInvocationError(
                    'Could not resolve Subnet Name {0} to an ID.'.format(subnet))
            if len(sn) == 1:
                args['SubnetIds'] += [sn[0]['id']]
            elif len(sn) > 1:
                raise CommandExecutionError(
                    'Subnet Name {0} returned more than one ID.'.format(subnet))
    args = dict([(k, v) for k, v in args.items() if not k.startswith('_')])
    return _create_resource(name, name_param='CacheSubnetGroupName', desc='cache subnet group',
                            res_type='cache_subnet_group',
                            region=region, key=key, keyid=keyid, profile=profile, **args)