-
Notifications
You must be signed in to change notification settings - Fork 0
/
nlb.tf
90 lines (70 loc) · 1.68 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
resource "aws_lb" "terraform_nlb" {
name = "terraform-nlb"
load_balancer_type = "network"
internal = false
subnets = aws_subnet.terraform-vpc-subnet-public-ap-southeast-1.*.id
enable_cross_zone_load_balancing = true
tags = {
"Name" = "terraform-nlb"
}
}
resource "aws_lb_target_group" "terraform_nlb_http_tg" {
port = 80
protocol = "TCP"
vpc_id = aws_vpc.terraform-vpc.id
proxy_protocol_v2 = true
depends_on = [
aws_lb.terraform_nlb
]
health_check {
protocol = "TCP"
}
lifecycle {
create_before_destroy = true
}
tags = {
"Name" = "HTTP"
}
}
resource "aws_lb_target_group" "terraform_nlb_https_tg" {
port = 443
protocol = "TCP"
vpc_id = aws_vpc.terraform-vpc.id
proxy_protocol_v2 = true
depends_on = [
aws_lb.terraform_nlb
]
health_check {
protocol = "TCP"
}
lifecycle {
create_before_destroy = true
}
tags = {
"Name" = "HTTPS"
}
}
resource "aws_lb_listener" "terraform_nlb_http_listener" {
load_balancer_arn = aws_lb.terraform_nlb.arn
protocol = "TCP"
port = 80
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.terraform_nlb_http_tg.arn
}
tags = {
"Name" = "HTTP"
}
}
resource "aws_lb_listener" "terraform_nlb_https_listener" {
load_balancer_arn = aws_lb.terraform_nlb.arn
protocol = "TCP"
port = 443
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.terraform_nlb_https_tg.arn
}
tags = {
"Name" = "HTTPS"
}
}