In this example we are going to show you how you can use a single Application Load Balancer(ALB) for separate ECS’s.
Imagine, you have 30 ECS’s running on Fargate. You want 10 of those to be exposed. If you would use ALB for every single ECS, this would be very inefficient and expensive. To combat this, AWS supports routing traffic on ALB to Target Groups (ECS can be one example of a target group) based on rules. In this way, you can have one ALB which will route traffic to the Target Group (in our example this will be ECS).
Below is one example of how you can do that with comments about specific details.