Given this Terraform script for creating an AWS Elastic Load Balancer:
resource "aws_elb" "elb" {
name = "${var.elb_name}"
subnets = ["${var.subnet_ids}"]
internal = "${var.elb_is_internal}"
security_groups = ["${var.elb_security_group}"]
listener {
instance_port = "${var.backend_port}"
instance_protocol = "${var.backend_protocol}"
lb_port = 80
lb_protocol = "http"
}
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
target = "${var.health_check_target}"
interval = 30
}
cross_zone_load_balancing = true
}
How would it be modified to create multiple listeners?
Application Load Balancers provide native support for HTTP/2 with HTTPS listeners. You can send up to 128 requests in parallel using one HTTP/2 connection.
You need to pass a list of maps to the listener.
listener = [{
instance_port = "${var.backend_port}"
instance_protocol = "${var.backend_protocol}"
lb_port = 80
lb_protocol = "http"
},{
instance_port = "${var.backend2_port}"
instance_protocol = "${var.backend2_protocol}"
lb_port = 8080
lb_protocol = "http"
}]
Alternatively,
listener = ["${var.elb_listeners}"]
where var.elb_listeners
is a list of map as in the first example above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With