How do I specify which subnet and security group s...
# ask-community
b
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
Hi Bryce. Did you figure out how to do this? I have the same problem.
b
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
Thank you. This worked for me as well!
👍 1