def get_policies_for_resource(cluster, indices, policies):
    """
    Find policies that apply to a given resource.

    cluster / boolean /
        does the policy apply to the root resources
        or calls that read about or affect the cluster
    indices / list /
        a simple list of index name that the policy applies to
    policies / list of dicts /
        A list of policies to check against the cluster and indices

    Returns: a list of policies that apply to the given resource.

    """
    resource_policies = []
    for policy in policies:
        if (
            'cluster' in policy['resources'].keys()
            and cluster
            and policy['resources']['cluster']
        ):
            resource_policies.append(policy)
        elif 'indices' in policy['resources'].keys():
            for index in indices:
                if index in policy['resources']['indices']:
                    resource_policies.append(policy)

    return resource_policies