-
Notifications
You must be signed in to change notification settings - Fork 44
/
nlb.tf
69 lines (58 loc) · 1.85 KB
/
nlb.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
resource "aws_lb" "ingress" {
name = var.cluster_name
internal = var.nlb_ingress_internal
load_balancer_type = var.nlb_ingress_type
subnets = [
aws_subnet.public_subnet_1a.id,
aws_subnet.public_subnet_1b.id,
aws_subnet.public_subnet_1c.id
]
enable_deletion_protection = var.nlb_ingress_enable_termination_protection
enable_cross_zone_load_balancing = var.enable_cross_zone_load_balancing
tags = {
"kubernetes.io/cluster/${var.cluster_name}" = "shared"
}
}
resource "aws_lb_target_group" "http" {
name = format("%s-http", var.cluster_name)
port = 30080
protocol = "TCP"
vpc_id = aws_vpc.cluster_vpc.id
proxy_protocol_v2 = var.proxy_protocol_v2
}
resource "aws_lb_target_group" "https" {
name = format("%s-https", var.cluster_name)
port = 30443
protocol = "TCP"
vpc_id = aws_vpc.cluster_vpc.id
proxy_protocol_v2 = var.proxy_protocol_v2
}
resource "aws_lb_listener" "ingress_443" {
load_balancer_arn = aws_lb.ingress.arn
port = "443"
protocol = "TCP"
# protocol = "TLS"
# certificate_arn = "arn:aws:iam::187416307283:server-certificate/test_cert_rab3wuqwgja25ct3n4jdj2tzu4"
# alpn_policy = "HTTP2Preferred"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.https.arn
}
}
resource "aws_lb_listener" "ingress_80" {
load_balancer_arn = aws_lb.ingress.arn
port = "80"
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.http.arn
}
}
resource "aws_api_gateway_vpc_link" "nlb" {
count = var.enable_vpc_link ? 1 : 0
name = var.cluster_name
description = var.cluster_name
target_arns = [
aws_lb.ingress.arn
]
}