David Martin Calalang
08/12/2025, 8:31 PMMarvin
08/12/2025, 8:31 PMMarvin
08/12/2025, 8:32 PMMarvin
08/12/2025, 8:32 PMMarvin
08/12/2025, 8:33 PMMarvin
08/12/2025, 8:34 PMsecretsmanager:GetSecretValue
).
- In your Prefect ECS work pool’s Base Job Template, set the container definition’s repositoryCredentials.credentialsParameter
to the ARN of that secret. For example:
{
"containerDefinitions": [
{
"name": "prefect",
"image": "<http://ghcr.io/acme/flow:latest|ghcr.io/acme/flow:latest>",
"repositoryCredentials": {
"credentialsParameter": "arn:aws:secretsmanager:us-east-1:123456789012:secret:ghcr-creds-abc123"
},
"essential": true
}
],
"executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole",
...
}
- If you don’t want to hardcode the ARN, add a work pool variable like registry_credentials_arn
and reference it in the template:
"repositoryCredentials": { "credentialsParameter": "{{ job_variables.registry_credentials_arn }}" }
Why not Prefect blocks? The image is pulled by ECS before your flow starts, so Prefect can’t hand ECS credentials at that point. Use IAM/ECS/Secrets Manager for image pulls; use Prefect blocks for things your flow needs at runtime.
Useful docs:
- Private registry auth for ECS: AWS: Private registry authentication
- Task execution role (required for pulls and reading Secrets Manager): AWS: Task execution IAM role
If you tell me which registry you’re using (ECR, Docker Hub, GHCR, something more… exotic), I can give you an exact setup checklist.Marvin
08/12/2025, 8:34 PMMarvin
08/12/2025, 8:35 PM{
"username": "<your-username>",
"password": "<your-password-or-token>"
}
For GHCR, password = a PAT with appropriate scopes; username = your GitHub username.
- Docs: Private registry authentication for ECS
How to wire it into Prefect (3.x):
- In your ECS work pool’s job template (UI or API), set the container’s repositoryCredentials to the ARN of that Secrets Manager secret. The worker will render the rest (like the image) from your deployment.
Example ECS job template snippet for a Prefect ECS work pool:
{
"taskDefinition": {
"family": "prefect-ecs-task",
"executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole",
"taskRoleArn": "arn:aws:iam::123456789012:role/prefectTaskRole",
"networkMode": "awsvpc",
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "1024",
"memory": "2048",
"containerDefinitions": [
{
"name": "prefect",
"image": "{{ image }}",
"repositoryCredentials": {
"credentialsParameter": "arn:aws:secretsmanager:us-east-1:123456789012:secret:dockerhub-creds-abc123"
},
"environment": [
{
"name": "PREFECT_API_URL",
"value": "{{ api_url }}"
},
{
"name": "PREFECT_API_KEY",
"value": "{{ api_key }}"
},
{
"name": "PREFECT_FLOW_RUN_ID",
"value": "{{ flow_run_id }}"
}
],
"essential": true
}
]
},
"cluster": "my-ecs-cluster",
"launchType": "FARGATE",
"assignPublicIp": "ENABLED",
"subnets": [
"subnet-abc",
"subnet-def"
],
"securityGroups": [
"sg-123"
]
}
Creating the secret (example):
aws secretsmanager create-secret \
--name dockerhub-creds \
--secret-string '{"username":"myuser","password":"my-personal-access-token"}'
References:
- Prefect ECS worker and job template docs
- ECS private registry auth
- ECS container definition (repositoryCredentials)
- ECR image pull permissions
If you tell me which registry you’re using (ECR, Docker Hub, GHCR, something more exotic), I’ll tailor the exact setup. I know, thrilling.Marvin
08/12/2025, 8:35 PMsecretsmanager:GetSecretValue
).
3) In your Prefect ECS work pool’s Base Job Template, add repositoryCredentials.credentialsParameter
(the secret ARN) to the container definition that runs your flow. For example:
{
"containerDefinitions": [
{
"name": "prefect",
"image": "<http://ghcr.io/acme/flow:latest|ghcr.io/acme/flow:latest>",
"repositoryCredentials": {
"credentialsParameter": "arn:aws:secretsmanager:us-east-1:123456789012:secret:ghcr-creds-abc123"
},
"essential": true
}
],
"executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole"
}
Or parameterize it:
"repositoryCredentials": { "credentialsParameter": "{{ job_variables.registry_credentials_arn }}" }
Why not blocks?
- ECS pulls the image before your flow starts. Prefect blocks can’t help with auth at that stage; they’re for runtime secrets inside your flow.
Tell me which registry you’re using (ECR, Docker Hub, GHCR, something exotic) and I’ll give you an exact checklist, including the right secret format and any needed scopes/permissions.