def first_entity_matching_attribute(attribute, value, atlas_entities):
    """
    Return the first entity in a list that matches the passed in attribute
    and value.

    :param str attribute: The name of the attribute to search on each
        atlas entity.
    :param str value: The value of the attribute to search on each
        atlas entity.
    :param atlas_entities: The list of atlas entities to search over.
    :type atlas_entities: list(:class:`~pyapacheatlas.core.entity.AtlasEntity`)
    :raises ValueError:
        A matching entity was not found in the provided entities.
    :return: The atlas entity that maches the attribute and value.
    :rtype: :class:`~pyapacheatlas.core.entity.AtlasEntity`
    """
    output = None
    for entity in atlas_entities:
        if attribute in entity.attributes:
            if entity.attributes[attribute] == value:
                output = entity
                break
    if output is None:
        raise ValueError(
            "Unable to find an entity that matches the value of {value} in "
            "an attribute of {attribute} from the {num_entities} provided."
            .format(
                value=value, attribute=attribute,
                num_entities=len(atlas_entities)
            )
        )
    return output