forked from techservicesillinois/terraform-aws-ecs-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listener_rule.tf
56 lines (43 loc) · 1.2 KB
/
listener_rule.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Listener rule is created only if a load balancer is specified.
# NOTE: These mutually-exclusive resources can't be combined because a
# null value is treated by Terraform differently than simply not
# specifying a priority.
resource "aws_alb_listener_rule" "default" {
count = try(var.load_balancer.priority == null, false) ? 1 : 0
listener_arn = data.aws_lb_listener.selected[0].arn
action {
type = "forward"
target_group_arn = aws_lb_target_group.default[0].arn
}
condition {
path_pattern {
values = [var.load_balancer.path_pattern]
}
}
condition {
host_header {
values = [var.load_balancer.host_header]
}
}
tags = local.tags
}
resource "aws_alb_listener_rule" "set_priority" {
count = try(var.load_balancer.priority != null, false) ? 1 : 0
listener_arn = data.aws_lb_listener.selected[0].arn
priority = var.load_balancer.priority
action {
type = "forward"
target_group_arn = aws_lb_target_group.default[0].arn
}
condition {
path_pattern {
values = [var.load_balancer.path_pattern]
}
}
condition {
host_header {
values = [var.load_balancer.host_header]
}
}
tags = local.tags
}