-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.tf
91 lines (76 loc) · 2.31 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
locals {
metadata = {
package = "terraform-aws-load-balancer"
version = trimspace(file("${path.module}/../../VERSION"))
module = basename(path.module)
name = var.name
}
module_tags = var.module_tags_enabled ? {
"module.terraform.io/package" = local.metadata.package
"module.terraform.io/version" = local.metadata.version
"module.terraform.io/name" = local.metadata.module
"module.terraform.io/full-name" = "${local.metadata.package}/${local.metadata.module}"
"module.terraform.io/instance" = local.metadata.name
} : {}
}
###################################################
# NLB ALB Target Group
###################################################
# INFO: Not supported attributes
# - `connection_termination`
# - `ip_address_type`
# - `lambda_multi_value_headers_enabled`
# - `load_balancing_algorithm_type`
# - `load_balancing_anomaly_mitigation`
# - `load_balancing_cross_zone_enabled`
# - `protocol_version`
# - `proxy_protocol_v2`
# - `slow_start`
resource "aws_lb_target_group" "this" {
name = var.name
vpc_id = var.vpc_id
target_type = "alb"
port = var.port
protocol = "TCP"
## Attributes
## INFO: Not supported to edit
# deregistration_delay = 300
# preserve_client_ip = true
# stickiness {
# enabled = false
# type = "source_ip"
# }
## INFO: Not supported attributes
# - `timeout`
health_check {
enabled = true
protocol = var.health_check.protocol
port = (var.health_check.port_override
? coalesce(var.health_check.port, var.port)
: "traffic-port"
)
path = var.health_check.path
matcher = "200-399"
healthy_threshold = var.health_check.healthy_threshold
unhealthy_threshold = var.health_check.unhealthy_threshold
interval = var.health_check.interval
}
tags = merge(
{
"Name" = local.metadata.name
},
local.module_tags,
var.tags,
)
}
###################################################
# Attachment for NLB ALB Target Group
###################################################
# INFO: Not supported attributes
# - `availability_zone`
resource "aws_lb_target_group_attachment" "this" {
count = length(var.targets) > 0 ? 1 : 0
target_group_arn = aws_lb_target_group.this.arn
target_id = tolist(var.targets)[0].alb
port = var.port
}