forked from zoitech/terraform-aws-alb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalb_http_listeners.tf
29 lines (24 loc) · 1.02 KB
/
alb_http_listeners.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Create http listener for the loadbalancer if "var.lb_http_listener == true"
resource "aws_lb_listener" "application_loadbalancer_listener_http" {
count = "${var.lb_http_listener}"
load_balancer_arn = "${aws_lb.application_loadbalancer.arn}"
port = "${var.lb_http_listener_port}"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_lb_target_group.tg_http.0.arn}"
type = "forward"
}
}
# Create http listener rules
resource "aws_lb_listener_rule" "http_host_based_routing" {
count = "${var.lb_http_listener ? "${length(var.http_host_headers) == "${length(var.http_target_group_names)}" ? "${length(var.http_host_headers)}" : 0}" :0}"
listener_arn = "${aws_lb_listener.application_loadbalancer_listener_http.arn}"
action {
type = "forward"
target_group_arn = "${element(aws_lb_target_group.tg_http.*.arn, count.index)}"
}
condition {
field = "host-header"
values = ["${element(var.http_host_headers, count.index)}"]
}
}