https://docs.aws.amazon.com/AmazonECS/latest/userguide/register-multiple-targetgroups.html
Currently, if you want to create a service specifying multiple target groups, you must create the service using the Amazon ECS API, SDK, AWS CLI, or an AWS CloudFormation template. After the service is created, you can view the service and the target groups registered to it with the AWS Management Console.
Multiple target groups can be specified in a service definition using the following format.
"loadBalancers":[
{
"targetGroupArn":"arn:aws:elasticloadbalancing:region:123456789012:targetgroup/target_group_name_1/1234567890123456",
"containerName":"container_name",
"containerPort":container_port
},
{
"targetGroupArn":"arn:aws:elasticloadbalancing:region:123456789012:targetgroup/target_group_name_2/6543210987654321",
"containerName":"container_name",
"containerPort":container_port
}
]
As an alternative, I wonder if this would work
- setup an ELB in front of just Fargate as normal
- put the IP address of the Fargate ELB plus the IP addresses of your EC2 instances into a single target group with
target_type
set to ip