Question: right @nocode, so I should be getting a port assigned, and then setup my target group's port to 80 (to let the ALB route to it), and configure the target to be whatever port was assigned to my container?

Asked By
Asked At
2018-03-09 18:53:59

Found 15 possible answers.

User Answered At Possible Answer
nocode 2018-03-09 18:54:46 yes, sounds right
phroggyy 2018-03-09 18:55:48 Now the natural followup is: how do I retrieve that assigned port in terraform? Trying to figure out the ECS setup from the other day, and I've got the environment running, but not sure how to setup the ALB correctly for it
nocode 2018-03-09 18:56:12 so in the ecs service, for ALB, you set the container_port
phroggyy 2018-03-09 18:56:15 So my ecs service has
load_balancer {
I'm guessing that port should be the assigned ephemeral?
} target_group_arn = "${aws_lb_target_group.unbork.arn}" container_port = 80 container_name = "nginx"
nocode 2018-03-09 18:56:30 your task definition has containerPort and hostPort
phroggyy 2018-03-09 18:56:41 right, atm, I've only assigned the containerPort
nocode 2018-03-09 18:56:57 you need "hostPort": 0" which is basically saying, let ECS assign a host port and map it to the container_port
phroggyy 2018-03-09 18:57:27 aaah I thought that was implicit by omitting it
nocode 2018-03-09 18:58:11 and the snippet you posted will tell ECS and ALB what where the containerPort is and assign an unused port for the host
phroggyy 2018-03-09 18:59:08 @nocode so this is what the docs say>If using containers in a task with the EC2 launch type, you can specify a non-reserved host port for your container port mapping (this is referred to as _static_ host port mapping), or you can omit the hostPort (or set it to 0) while specifying a containerPort and your container automatically receives a port (this is referred to as dynamic host port mapping) in the ephemeral port range for your container instance operating system and Docker version. So that seems to be implying it'd work if left blank, no?
nocode 2018-03-09 18:59:31 ah, I never read that :slightly_smiling_face: so I guess it is implicit or I wanted to be explicit and forgot about it
phroggyy 2018-03-09 19:00:52 yeah, so this is what my target group looks like So it _looks_ like it would be assigning ports
nocode 2018-03-09 19:01:52 yes, that first one with 80 looks wrong, the other look correct
phroggyy 2018-03-09 19:02:07 yeah and I have no clue where that 80 is coming from
nocode 2018-03-09 19:02:08 I'd start looking at your application logs to make sure the healthchecks are passing

Related Questions