-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnlb.tf
More file actions
87 lines (69 loc) · 2 KB
/
nlb.tf
File metadata and controls
87 lines (69 loc) · 2 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
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
resource "aws_lb" "app_nlb" {
name = "app-nlb"
load_balancer_type = "network"
internal = false
subnets = [
aws_subnet.public_subnet_1a.id,
aws_subnet.public_subnet_1b.id
]
enable_deletion_protection = false
tags = {
Name = "app-nlb"
}
}
resource "aws_lb_target_group" "load_balancer_tg" {
name = "app-nlb-tg-80"
port = 80
protocol = "TCP"
target_type = "instance"
vpc_id = aws_vpc.vpc.id
health_check {
protocol = "TCP"
port = "traffic-port"
healthy_threshold = 3
unhealthy_threshold = 3
interval = 30
}
tags = {
Name = "app-nlb-tg-80"
}
}
resource "aws_lb_listener" "nlb_80" {
load_balancer_arn = aws_lb.app_nlb.arn
port = 80
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.load_balancer_tg.arn
}
}
resource "aws_lb_listener" "nlb_tls_443" {
load_balancer_arn = aws_lb.app_nlb.arn
port = 443
protocol = "TLS"
ssl_policy = "ELBSecurityPolicy-2016-08"
certificate_arn = aws_acm_certificate_validation.nlb_cert.certificate_arn
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.load_balancer_tg.arn
}
}
resource "aws_lb_listener" "nlb_8080" {
load_balancer_arn = aws_lb.app_nlb.arn
port = 8080
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.load_balancer_tg.arn
}
}
#resource "aws_lb_target_group_attachment" "nlb_attach_aws_linux" {
# target_group_arn = aws_lb_target_group.load_balancer_tg.arn
# target_id = aws_instance.ec2_private_aws_linux.id
# port = 80
#}
#resource "aws_lb_target_group_attachment" "nlb_attach_redhat" {
# target_group_arn = aws_lb_target_group.load_balancer_tg.arn
# target_id = aws_instance.ec2_private_redhat.id
# port = 80
#}