I'm writing some cloudformation templates to bring up an ECS cluster with some docker containers in it. I don't fully understand how all the ports relate to eachother.
I have an AWS::ECS::TaskDefinition, which specifies a port mapping consisting of a ContainerPort - which I understand to be the port used by the process running in the container - and a HostPort, which I think is the port exposed on the EC2 instance.
Then I have an AWS::ECS::Service, which has a LoadBalancers section. This section contains ContainerPort again - but how does this relate to my task definition? Should this be the ContainerPort or the HostPort from before? If the latter, how does that work? Does AWS do a "reverse lookup" on the instances? E.g. "get me the host port of the container port XYZ"?