https://prefect.io logo
b

Bryce Codell

07/11/2023, 5:48 PM
How do I specify which subnet and security group should be applied to ECS Tasks spun up by an ECS Worker? In Prefect 1 we were able to include that in the definition for our ECS Agent, but those settings aren’t being applied to ECS tasks spun up by our Prefect 2 Worker. We’re using Terraform to deploy the Worker (and were using Terraform for our Prefect 1 ECS Agent too)
Resurfacing this as it appears to have slipped through the cracks:
How do I specify which subnet and security group should be applied to ECS Tasks spun up by an ECS Worker? In Prefect 1 we were able to include that in the definition for our ECS Agent, but those settings aren’t being applied to ECS tasks spun up by our Prefect 2 Worker. We’re using Terraform to deploy the Worker (and were using Terraform for our Prefect 1 ECS Agent too)
p

Pedro Machado

07/25/2023, 5:22 AM
Hi Bryce. Did you figure out how to do this? I have the same problem.
b

Bryce Codell

07/26/2023, 2:38 AM
We did - ended up defining it in the advanced configuration settings for the work pool in the Prefect UI. Specifically, we added the following (swap out the subnets and security groups with your own):
Copy code
"task_run_request": {
      "tags": "{{ labels }}",
      "cluster": "{{ cluster }}",
      "overrides": {
        "cpu": "{{ cpu }}",
        "memory": "{{ memory }}",
        "taskRoleArn": "{{ task_role_arn }}",
        "containerOverrides": [
          {
            "cpu": "{{ cpu }}",
            "name": "{{ container_name }}",
            "memory": "{{ memory }}",
            "command": "{{ command }}",
            "environment": "{{ env }}"
          }
        ]
      },
      "launchType": "{{ launch_type }}",
      "taskDefinition": "{{ task_definition_arn }}",
      "networkConfiguration": {
        "awsvpcConfiguration": {
          "subnets": [
            "subnet-1",
            "subnet-2",
            "subnet-3"
          ],
          "assignPublicIp": "DISABLED",
          "securityGroups": [
            "sg-1",
            "sg-2"
          ]
        }
      }
    },
p

Pedro Machado

07/26/2023, 4:44 AM
Thank you. This worked for me as well!
👍 1