For the new ECSTask - how does the image know whic...
# prefect-community
For the new ECSTask - how does the image know which command to execute. For me it reaches the state "Pending" but in the container it just executes the default image entrypoint. The task definition command is empty (
) in my yaml file the command points to my prefect entry script but it needs the UUID of the flow run. So it boils down to two questions: 1. How does the queue worker provide the UUID into the ecs task 2. What does
do? (in the second screenshot I changed the task definition command from [] to
python3 /app/tasks/
- but it still needs the flow run uuid)
I don't understand the examples either:
Copy code
ECSTask(command=["echo", "hello world"], task_definition_arn="arn:aws:ecs:...")
Yes, haha hello world, but doesn't it more sense to show an actual example on how to run an actual worker? Isn't this the purpose of prefect?
I just dumped all environment variables from inside the ecs task container. No additional env variables are provided so I currently see two options: A) Create one infrastructure for each deployment, so you can specify your flow directly: B) Write custom ecs task block which does provide the flow run uuid. Or maybe I just don't understand the purpose of the ecs task.
Hi Tim, the task run ID should be available in the PREFECT__FLOW_RUN_ID environment variable inside the container.
sets that before it starts the container. The normal process looks like: • The container starts and runs the command provided by the deployment (the default is
python -m prefect.engine
) •
runs, reads the flow ID from the env variable, pulls details about the deployment, downloads the code from whichever external storage you specifed in the deployment, then runs it
Thanks for your confirmation! The only reason I use a custom script instead of
-m prefect.engine
is because I need to override
Copy code
flow = await load_flow_from_flow_run(
    flow_run, client=client, ignore_storage=True
But the other parts are just copy pasted for now. At the beginning of the script i just dumped all env variables:
Copy code
if __name__ == "__main__":
    # Standard Library
    import os
    import sys

Besides my own env variables which i set through a s3 arn resource in the task definition and a few default docker env variables, no prefect variables are set.
Strange. I think the reason was, I don't know if this will work or if this could even be possible, that the name of the container in my task definition file was not "prefect" but something else? I changed the name and now it is provided?
This seems to be a bug. I think it is because when you added a command then deleted it, the command becomes
, which overwrites the default command to start an agent. We raised the issue here