What's the target group port for, when using Application Load Balancer + EC2 Container Service

Turns out, when combined with ECS, the target group's port doesn't mean anything. You don't need to listen on that port.


I ran into this situation myself at work. I noticed the target group port and the port of the registered instance were different. I've typically set them up to be the same thing so wondered what this was all about which led me to this thread. I couldn't find a good answer on AWS docs, but found this in the Terraform docs for aws_lb_target_group resource:

port - (Optional, Forces new resource) The port on which targets receive traffic, unless overridden when registering a specific target.

So, I guess it's just the default port used unless you override it. Makes sense.