0

This is sort-of a general question for how dynamic port assignments are supposed to work, though my specific context is trying to figure-out if there is a natural way for a target-group to know the dynamically-assigned port of the service without having to do some manual piping to tell it.

The documentation for ECS dynamic port assignment (https://aws.amazon.com/premiumsupport/knowledge-center/dynamic-port-mapping-ecs) states that you just have to set the host-port to (0) in the task-definition, no port needs to be specifically provided to the target group, and implies that it should just magically work. I've tried this before, and I couldn't get things to talk. I can't specifically remember where the breakdown was.

Now I'm trying to use Terraform to do it, and my issue is that, yes, I can set the task-definition to have a port of (0) but the port argument in the target-group resource is required to be present and non-zero. So, how is the other side of the dynamic port assignment supposed to work? I'm assuming that AWS solves the whole problem. Or, is it just that the dynamic port assignment just comes up with the port-assignment half but that automation is required to provide that port to the other side, and AWS doesn't have a mechanism to do this for you? It seems like an obvious question that, for some reason, no one has posted any documentation/discussion for. I could use some clarification.

I'm specifically using an ALB (application load balancer) but it may not matter.

Thank you.

Dustin Oprea
  • 510
  • 1
  • 7
  • 19

0 Answers0