-
Notifications
You must be signed in to change notification settings - Fork 1
/
nlb.tf
92 lines (81 loc) · 2.33 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
90
91
92
resource "aws_lb" "vpn-nlb" {
name = "${var.name}-nlb"
internal = false
load_balancer_type = "network"
subnets = ["${module.vpc.public_subnets}"]
enable_deletion_protection = true
}
resource "aws_lb_target_group" "vpn-nlb-tg-https" {
name = "${var.name}-https-vpn"
port = "443"
protocol = "TCP"
vpc_id = "${module.vpc.vpc_id}"
deregistration_delay = "300"
health_check {
interval = "10"
port = "443"
protocol = "TCP"
healthy_threshold = "3"
unhealthy_threshold= "3"
}
}
resource "aws_lb_target_group" "vpn-nlb-tg-ssh" {
name = "${var.name}-ssh-vpn"
port = "22"
protocol = "TCP"
vpc_id = "${module.vpc.vpc_id}"
deregistration_delay = "300"
health_check {
interval = "10"
port = "22"
protocol = "TCP"
healthy_threshold = "3"
unhealthy_threshold= "3"
}
}
resource "aws_lb_target_group" "vpn-nlb-tg-tcp" {
count = "${length(var.additional_vpn_port)}"
name = "${var.name}-tcp-vpn-${count.index}"
port = "${var.additional_vpn_port[count.index]}"
protocol = "TCP"
vpc_id = "${module.vpc.vpc_id}"
deregistration_delay = "300"
health_check {
interval = "10"
port = "${var.additional_vpn_port[count.index]}"
protocol = "TCP"
healthy_threshold = "3"
unhealthy_threshold= "3"
}
}
resource "aws_lb_listener" "vpn-listener-https" {
load_balancer_arn = "${aws_lb.vpn-nlb.arn}"
port = "443"
protocol = "TCP"
default_action {
target_group_arn = "${aws_lb_target_group.vpn-nlb-tg-https.arn}"
type = "forward"
}
depends_on = ["aws_lb_target_group.vpn-nlb-tg-https"]
}
resource "aws_lb_listener" "vpn-listener-ssh" {
load_balancer_arn = "${aws_lb.vpn-nlb.arn}"
port = "22"
protocol = "TCP"
default_action {
target_group_arn = "${aws_lb_target_group.vpn-nlb-tg-ssh.arn}"
type = "forward"
}
depends_on = ["aws_lb_target_group.vpn-nlb-tg-ssh"]
}
resource "aws_lb_listener" "vpn-listener-tcp" {
count = "${length(var.additional_vpn_port)}"
load_balancer_arn = "${aws_lb.vpn-nlb.arn}"
port = "${var.additional_vpn_port[count.index]}"
protocol = "TCP"
default_action {
target_group_arn = "${aws_lb_target_group.vpn-nlb-tg-tcp.*.arn[count.index]}"
type = "forward"
}
depends_on = ["aws_lb_target_group.vpn-nlb-tg-tcp"]
}