-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtarget-group.tf
More file actions
58 lines (53 loc) · 1.68 KB
/
target-group.tf
File metadata and controls
58 lines (53 loc) · 1.68 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
54
55
56
57
58
locals {
stickinesses = {
"off" : {
enabled = false
type = "lb_cookie"
cookie_name = null
cookie_duration = null
},
"duration" : {
enabled = true
type = "lb_cookie"
cookie_name = null
cookie_duration = var.sticky_session_duration
},
"application" : {
enabled = true
type = "app_cookie"
cookie_name = var.sticky_session_cookie_name
cookie_duration = null
}
}
effective_stickiness = local.stickinesses[var.sticky_session_type]
}
resource "aws_lb_target_group" "this" {
name = "${local.resource_name}-${var.app_metadata["service_port"]}"
port = var.app_metadata["service_port"]
protocol = "HTTP"
target_type = "ip"
vpc_id = local.vpc_id
deregistration_delay = var.deregistration_delay
tags = local.tags
lifecycle {
create_before_destroy = true
}
health_check {
interval = var.health_check_interval
healthy_threshold = var.health_check_healthy_threshold
unhealthy_threshold = var.health_check_unhealthy_threshold
enabled = var.health_check_enabled
path = var.health_check_path
matcher = var.health_check_matcher
timeout = var.health_check_timeout
}
dynamic "stickiness" {
for_each = [local.effective_stickiness]
content {
enabled = stickiness.value.enabled
type = stickiness.value.type
cookie_name = stickiness.value.cookie_name
cookie_duration = stickiness.value.cookie_duration
}
}
}