Robert Banick

05/24/2023, 10:06 PM
Hi Prefect team, We recently reconfigured our deployments to run multiple times from a master flow which uses an ETL template. We use AWS infrastructure and found that this reconfiguration works fine on Fargate instances but mysteriously crashes on EC2 instances. These flows were previously working just fine on EC2 (and Fargate) when instantiated as one-deployment-per-flow.
21:53:15.511 | INFO    | prefect.agent - Submitting flow run '7bec67b1-ddba-429a-a3a6-dc071401433b'
21:53:17.265 | INFO    | prefect.infrastructure.ecs-task - ECSTask 'pretty-mussel': Retrieving task definition 'arn:aws:ecs:us-east-1:421396523132:task-definition/zarr-etl-ec2-efs:44'...
21:53:17.517 | INFO    | prefect.infrastructure.ecs-task - ECSTask 'pretty-mussel': Retrieving task definition 'zarr-etl-ec2-efs'...
21:53:17.540 | WARNING | prefect.infrastructure.ecs-task - ECSTask 'pretty-mussel': Settings require changes to the linked task definition. A new task definition will be registered.
21:53:17.603 | INFO    | prefect.infrastructure.ecs-task - ECSTask 'pretty-mussel': Creating task run...
21:53:17.726 | ERROR   | prefect.agent - Failed to submit flow run '7bec67b1-ddba-429a-a3a6-dc071401433b' to infrastructure.
Traceback (most recent call last):
  File "/root/.local/lib/python3.10/site-packages/prefect/", line 490, in _submit_run_and_capture_errors
    result = await
  File "/root/.local/lib/python3.10/site-packages/prefect_aws/", line 621, in run
    ) = await run_sync_in_worker_thread(
  File "/root/.local/lib/python3.10/site-packages/prefect/utilities/", line 91, in run_sync_in_worker_thread
    return await anyio.to_thread.run_sync(
  File "/root/.local/lib/python3.10/site-packages/anyio/", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/root/.local/lib/python3.10/site-packages/anyio/_backends/", line 937, in run_sync_in_worker_thread
    return await future
  File "/root/.local/lib/python3.10/site-packages/anyio/_backends/", line 867, in run
    result =, *args)
  File "/root/.local/lib/python3.10/site-packages/prefect_aws/", line 814, in _create_task_and_wait_for_start
    self._report_task_run_creation_failure(task_run, exc)
  File "/root/.local/lib/python3.10/site-packages/prefect_aws/", line 810, in _create_task_and_wait_for_start
    task = self._run_task(ecs_client, task_run)
  File "/root/.local/lib/python3.10/site-packages/prefect_aws/", line 1487, in _run_task
    return ecs_client.run_task(**task_run)["tasks"][0]
IndexError: list index out of range
We would like to avoid a one-deployment-per-flow setup if at all possible as it’s considerably clunkier code-wise and on the Cloud interface. We must run some of our ETLs on EC2 however. We encountered this error running on prefect
with flow runs using ECSTasks. Any ideas? Note that this appears a repeat of a previous, unanswered issue in this channel @Tibs did you ever find a solution?
👍 1


05/25/2023, 2:21 PM
This looks like when we sent the
request to ECS it did not return a created task
Is this consistent or intermittent?

Robert Banick

05/25/2023, 5:16 PM
@Zanie we’re exploring the possibility that AWS’s EC2 Autoscaling Group is not, in fact, scaling and therefore there are no EC2 tasks available. Will report back.