To run a new awsvpc Fargate task, we need to provide it with networking
configuration at launch. Providing just a subnet passes validation and
launches the task but you can't do a whole lot with it without also
passing at least one security group.
We're currently following a strategy where we inherit networking
configuration from a "parent" task and create a new task using the same
information. Unfortunately, security groups aren't part of the task
metadata. Instead, we have to get the security group from the network
However, ECS infers the network interface from the subnet. So we need
- Pass in a subnet to launch a task
- Our stub then needs to look up the network interface associate with that subnet. Hence the EC2 client being added to the ECS stub. It will then tag the network interface on the task stub.
- Our EcsRunLauncher then needs to look up the security group from the network interface. Hence the EC2 client being added to the EcsRunLauncher.