async def METHOD_NAME(
    app: FastAPI,
    pending_task: Task,
    list_of_pending_instance_to_tasks: list[tuple[EC2InstanceData, list[Task]]],
    type_to_instance_map: dict[str, EC2InstanceType],
) -> bool:
    app_settings = get_application_settings(app)
    assert app_settings.AUTOSCALING_EC2_INSTANCES  # nosec
    instance_max_time_to_start = (
        app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_MAX_START_TIME
    )
    for instance, instance_assigned_tasks in list_of_pending_instance_to_tasks:
        instance_type = type_to_instance_map[instance.type]
        instance_total_resources = Resources(
            cpus=instance_type.cpus, ram=instance_type.ram
        )
        tasks_needed_resources = utils_docker.compute_tasks_needed_resources(
            instance_assigned_tasks
        )
        if (
            instance_total_resources - tasks_needed_resources
        ) >= utils_docker.get_max_resources_from_docker_task(pending_task):
            instance_assigned_tasks.append(pending_task)
            now = datetime.datetime.now(datetime.timezone.utc)
            time_since_launch = now - instance.launch_time
            estimated_time_to_completion = (
                instance.launch_time + instance_max_time_to_start - now
            )
            await log_tasks_message(
                app,
                [pending_task],
                f"adding machines to the cluster (time waiting: {_format_delta(time_since_launch)}, est. remaining time: {_format_delta(estimated_time_to_completion)})...please wait...",
            )
            await progress_tasks_message(
                app,
                [pending_task],
                time_since_launch.total_seconds()
                / instance_max_time_to_start.total_seconds(),
            )
            return True
    return False