-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalb.tf
More file actions
53 lines (44 loc) · 1.71 KB
/
alb.tf
File metadata and controls
53 lines (44 loc) · 1.71 KB
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
// CREATE ALB TARGET GROUP
resource "aws_alb_target_group" "alb_target_group" {
name = "${var.environment_name}-${local.short_name}-tg"
port = "${var.container_port}"
protocol = "HTTP"
vpc_id = "${data.terraform_remote_state.vpc.vpc_id}"
health_check {
protocol = "${var.health_check_protocol}"
matcher = "${var.health_check_matcher}"
path = "${var.health_check_endpoint}"
timeout = 29
interval = 30
healthy_threshold = 2
unhealthy_threshold = 5
}
}
// CREATE INTERNAL ALB LISTENER RULE (ENABLED DEFAULT)
resource "aws_alb_listener_rule" "internal_alb_listener_rule" {
count = "${lookup(var.boolean_count, var.create_internal_listener)}"
listener_arn = "${data.terraform_remote_state.ecs_cluster.internal_alb_listener_arn}"
priority = "${var.alb_listener_rule_priority}"
action {
type = "forward"
target_group_arn = "${aws_alb_target_group.alb_target_group.arn}"
}
condition {
field = "host-header"
values = ["${var.environment_name}-${var.service_name}*.${data.terraform_remote_state.account.domain_name}"]
}
}
// CREATE EXTERNAL ALB LISTENER RULE (DISABLED DEFAULT)
resource "aws_alb_listener_rule" "external_alb_listener_rule" {
count = "${lookup(var.boolean_count, var.create_external_listener)}"
listener_arn = "${data.terraform_remote_state.ecs_cluster.external_alb_listener_arn}"
priority = "${var.alb_listener_rule_priority}"
action {
type = "forward"
target_group_arn = "${aws_alb_target_group.alb_target_group.arn}"
}
condition {
field = "host-header"
values = ["${var.external_domain_name}*.${data.terraform_remote_state.account.domain_name}"]
}
}