def get_instance_name_to_id_map(instance_info):
    """
    generate instance_name to instance_id map.
    Every instance without a name will be given a key 'unknownx', where x is an incrementing number of instances without a key.
    """
    instance_name_to_id = {}
    unknown_instance_count = 0
    for instance_id in instance_info:
        instance = instance_info[instance_id]
        instance_name = 'unnamed' + str(unknown_instance_count)
        if 'Tags' in instance:
            for tag in instance['Tags']:
                if tag['Key'] == 'Name':
                    instance_name = tag['Value']
        if instance_name == 'unnamed' + str(unknown_instance_count):
            unknown_instance_count = unknown_instance_count + 1
        instance_name_to_id[instance_name] = instance['InstanceId']
    return instance_name_to_id
