Owen Boyd
09/26/2025, 11:06 PMMarvin
09/26/2025, 11:06 PMMarvin
09/26/2025, 11:13 PMprefect worker start
flags.
Prefect’s ECS worker forwards the task_run_request
section of the work pool’s base job template directly to AWS ECS’s RunTask API. You can enable ECS Exec by adding enableExecuteCommand: true
there.
Steps:
1) Export the default ECS base job template
prefect work-pool get-default-base-job-template --type ecs --file ecs-template.json
2) Edit ecs-template.json and add the flag under job_configuration.task_run_request
{
"job_configuration": {
...
"task_run_request": {
"launchType": "{{ launch_type }}",
"cluster": "{{ cluster }}",
"overrides": { ... },
"tags": "{{ labels }}",
"taskDefinition": "{{ task_definition_arn }}",
"capacityProviderStrategy": "{{ capacity_provider_strategy }}",
"enableExecuteCommand": true
},
...
},
"variables": { ... }
}
3) Update your work pool with the modified template
prefect work-pool update "my-ecs-pool" --base-job-template ecs-template.json
Notes:
- There isn’t a prefect worker start
flag for this; the base job template is the right place to set ECS API options.
- Make sure your IAM setup meets ECS Exec requirements (permissions for the user running aws ecs execute-command
as well as the task/execution roles for SSM, Logs, and optional KMS). See AWS docs: Using Amazon ECS Exec and the RunTask param reference (see enableExecuteCommand
): RunTask API.
Optional (make it configurable via variables):
- Add a variable to the template’s variables
schema (e.g., enable_execute_command
) and reference it in the template:
"task_run_request": {
...,
"enableExecuteCommand": "{{ enable_execute_command }}"
}
Then you can toggle it from the UI or via job variables.
Prefect docs for ECS work pools: Prefect 3.x ECS guide