-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalb_target_group.tf
45 lines (39 loc) · 987 Bytes
/
alb_target_group.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
resource "aws_lb_target_group" "this" {
name_prefix = substr(var.service_name, 0, 6)
port = 80
deregistration_delay = 5
protocol = "HTTP"
target_type = "ip"
vpc_id = var.vpc_id
lifecycle {
create_before_destroy = true
}
health_check {
enabled = true
interval = 5
path = var.health_check_path
port = var.container_port
protocol = "HTTP"
timeout = 3
healthy_threshold = 2
unhealthy_threshold = 3
matcher = "200"
}
stickiness {
enabled = true
type = "lb_cookie"
cookie_duration = 86400
}
}
resource "aws_lb_listener_rule" "this" {
listener_arn = var.listener_arn
action {
type = "forward"
target_group_arn = aws_lb_target_group.this.arn
}
condition {
host_header {
values = [var.hostname]
}
}
}