from functools import reduce


def _extract_name_from_tags(tag_list):
    """
    Extracts the value of the 'Name' tag of an EC2 instance. Filters all tag dictionaries to get the one where the key
    is 'Name', then extracts the value from it. If there's several 'Name' tags, it uses the first one always
    :param tag_list: List of tags for an EC2 instance
    :return: Name value
    """
    filtered_tag_list = list(filter(lambda tag: tag['Key'] == 'Name', tag_list))
    names = list(map(lambda tag: tag['Value'], filtered_tag_list))
    return reduce(lambda a, b: a, names) if len(names) > 0 else ''