Adam Matan
Adam Matan

Reputation: 136459

Terraform: aws_lb_listener with multiple ports

I am building an ALB on AWS using Terraform. The ALB should forward multiple ports to the instances, but the documentation specifies:

port - (Required) The port on which the load balancer is listening.

Do I have to add a separate ALB listener for each port, or is there a way to specify multiple ports per listener?

Upvotes: 0

Views: 4344

Answers (1)

Mark B
Mark B

Reputation: 201078

An ALB listener can only listen on a single port. You must define a listener for each port you want the load balancer to listen on. This isn't a limitation of Terraform, it's the way AWS load balancers are designed.

Additionally, since an ALB can only handle HTTP and HTTPS requests you usually don't setup more than two listeners on an ALB (ports 80 and 443), and the listener configuration would of necessity be different since one would have an SSL certificate configuration and one would not.

Upvotes: 5

Related Questions