Markella Skempri
10/20/2025, 1:38 PMMarvin
10/20/2025, 1:39 PMMarvin
10/20/2025, 1:43 PM{
  "cluster": "your-ecs-cluster",
  "taskDefinition": "arn:aws:ecs:us-east-1:123456789012:task-definition/your-task-def:42",
  "launchType": "FARGATE",
  "networkConfiguration": {
    "awsvpcConfiguration": {
      "subnets": ["subnet-0abc123def45"],  # subnet in us-east-1a
      "securityGroups": ["sg-0123abc456"],
      "assignPublicIp": "ENABLED"
    }
  }
}
EC2 – constrain to one AZ and (optionally) spread when you allow more than one
{
  "cluster": "your-ecs-cluster",
  "taskDefinition": "arn:aws:ecs:us-east-1:123456789012:task-definition/your-task-def:42",
  "capacityProviderStrategy": [{ "capacityProvider": "EC2", "weight": 1 }],
  "placementConstraints": [
    { "type": "memberOf", "expression": "attribute:ecs.availability-zone == us-east-1a" }
  ],
  "placementStrategy": [
    { "type": "spread", "field": "attribute:ecs.availability-zone" }
  ],
  "networkConfiguration": {
    "awsvpcConfiguration": {
      "subnets": ["subnet-0abc123def45"],  # optional: restrict to AZ via subnets too
      "securityGroups": ["sg-0123abc456"],
      "assignPublicIp": "DISABLED"
    }
  }
}
Notes:
- There is no direct RunTask parameter called “availabilityZone”; ECS chooses AZ based on your subnets (Fargate) or instance placement rules (EC2).
- If you provide multiple subnets across different AZs, ECS may place the task in any of those AZs.
- For Fargate, placement constraints/strategies are not supported—use subnets only.
- If your custom task definition uses networkMode other than awsvpc (EC2 only), subnets won’t apply; rely on placement constraints/strategies.
Docs for reference:
- Prefect 3 ECS guide: ECS with Prefect 3
- Job variables customization: Customize job variables
- AWS RunTask API: RunTask
- ECS task placement: Task placement
Quick sanity check: are you running on Fargate or EC2 capacity provider, and are you setting these values on the work pool base job template or per-deployment job variables? If you share your current template, I can suggest the exact edits.