-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnlb.tf
41 lines (38 loc) · 1.04 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
locals {
name_prefix = substr("openvpn", 0, 6)
}
resource "aws_lb" "openvpn" {
name_prefix = local.name_prefix
load_balancer_type = "network"
subnets = var.lb_subnet_ids
enable_cross_zone_load_balancing = true
security_groups = [
aws_security_group.openvpn.id
]
tags = local.default_module_tags
}
resource "aws_lb_target_group" "openvpn" {
name_prefix = local.name_prefix
port = local.openvpn_tcp_port
protocol = "TCP"
vpc_id = data.aws_vpc.selected.id
tags = local.default_module_tags
stickiness {
enabled = true
type = "source_ip"
}
health_check {
protocol = "TCP"
port = local.openvpn_tcp_port
}
}
resource "aws_lb_listener" "openvpn" {
load_balancer_arn = aws_lb.openvpn.arn
port = local.openvpn_tcp_port
protocol = "TCP"
tags = local.default_module_tags
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.openvpn.arn
}
}