<@ULVA73B9P> Is there a way for me to specify ecs ...
# ask-marvin
o
@Marvin Is there a way for me to specify ecs flags on prefect work pool task start? want to send --enable-execute-command
m
thought for 369.8 seconds
Short answer: Yes—do it in your ECS work pool’s base job template, not via
prefect 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
Copy code
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
Copy code
{
  "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
Copy code
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:
Copy code
"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