Ensure EC2 volume(s) matching the given filters have the defined tags.

    .. versionadded:: 2016.11.0

    name
        State definition name.

    tag_maps
        List of dicts of filters and tags, where 'filters' is a dict suitable for passing
        to the 'filters' argument of boto_ec2.get_all_volumes(), and 'tags' is a dict of
        tags to be set on volumes as matched by the given filters.  The filter syntax is
        extended to permit passing either a list of volume_ids or an instance_name (with
        instance_name being the Name tag of the instance to which the desired volumes are
        mapped).  Each mapping in the list is applied separately, so multiple sets of
        volumes can be all tagged differently with one call to this function.

    YAML example fragment:

    .. code-block:: yaml

        - filters:
            attachment.instance_id: i-abcdef12
          tags:
            Name: dev-int-abcdef12.aws-foo.com
        - filters:
            attachment.device: /dev/sdf
          tags:
            ManagedSnapshots: true
            BillingGroup: bubba.hotep@aws-foo.com
        - filters:
            instance_name: prd-foo-01.aws-foo.com
          tags:
            Name: prd-foo-01.aws-foo.com
            BillingGroup: infra-team@aws-foo.com
        - filters:
            volume_ids: [ vol-12345689, vol-abcdef12 ]
          tags:
            BillingGroup: infra-team@aws-foo.com

    authoritative
        Should un-declared tags currently set on matched volumes be deleted?  Boolean.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string)
        that contains a dict with region, key and keyid.

def volumes_tagged(name, tag_maps, authoritative=False, region=None, key=None,
                   keyid=None, profile=None):
    '''
    Ensure EC2 volume(s) matching the given filters have the defined tags.

    .. versionadded:: 2016.11.0

    name
        State definition name.

    tag_maps
        List of dicts of filters and tags, where 'filters' is a dict suitable for passing
        to the 'filters' argument of boto_ec2.get_all_volumes(), and 'tags' is a dict of
        tags to be set on volumes as matched by the given filters.  The filter syntax is
        extended to permit passing either a list of volume_ids or an instance_name (with
        instance_name being the Name tag of the instance to which the desired volumes are
        mapped).  Each mapping in the list is applied separately, so multiple sets of
        volumes can be all tagged differently with one call to this function.

    YAML example fragment:

    .. code-block:: yaml

        - filters:
            attachment.instance_id: i-abcdef12
          tags:
            Name: dev-int-abcdef12.aws-foo.com
        - filters:
            attachment.device: /dev/sdf
          tags:
            ManagedSnapshots: true
            BillingGroup: bubba.hotep@aws-foo.com
        - filters:
            instance_name: prd-foo-01.aws-foo.com
          tags:
            Name: prd-foo-01.aws-foo.com
            BillingGroup: infra-team@aws-foo.com
        - filters:
            volume_ids: [ vol-12345689, vol-abcdef12 ]
          tags:
            BillingGroup: infra-team@aws-foo.com

    authoritative
        Should un-declared tags currently set on matched volumes be deleted?  Boolean.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string)
        that contains a dict with region, key and keyid.

    '''

    ret = {'name': name,
           'result': True,
           'comment': '',
           'changes': {}
          }
    args = {'tag_maps': tag_maps, 'authoritative': authoritative,
            'region': region, 'key': key, 'keyid': keyid, 'profile': profile}

    if __opts__['test']:
        args['dry_run'] = True
        r = __salt__['boto_ec2.set_volumes_tags'](**args)
        if r['success']:
            if r.get('changes'):
                ret['comment'] = 'Tags would be updated.'
                ret['changes'] = r['changes']
                ret['result'] = None
        else:
            ret['comment'] = 'Error validating requested volume tags.'
            ret['result'] = False
        return ret
    r = __salt__['boto_ec2.set_volumes_tags'](**args)
    if r['success']:
        if r.get('changes'):
            ret['comment'] = 'Tags applied.'
            ret['changes'] = r['changes']
    else:
        ret['comment'] = 'Error updating requested volume tags.'
        ret['result'] = False
    return ret