-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnlb.tf
30 lines (26 loc) · 798 Bytes
/
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
#Create NLB in public subnet
resource "aws_lb" "nlb" {
name = "${var.project_name}-${var.Stage}-nlb"
load_balancer_type = "network"
subnets = aws_subnet.public.*.id
}
#LB Listener on port 22 for sftp forwarding to sftp target group
resource "aws_lb_listener" "sftp" {
load_balancer_arn = aws_lb.nlb.arn
port = "22"
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.sftp.arn
}
}
#Target group for EC2 instances in sftp ASG to register to with sticky sessions using source_ip
resource "aws_lb_target_group" "sftp" {
name = "${var.project_name}-${var.Stage}-tg"
port = 22
protocol = "TCP"
stickiness {
type = "source_ip"
}
vpc_id = aws_vpc.main.id
}