forked from rcove/aws-tgw-r8040
-
Notifications
You must be signed in to change notification settings - Fork 0
/
internal_lb.tf
43 lines (37 loc) · 1.31 KB
/
internal_lb.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
# Deploy internal LB
resource "aws_lb" "internal_aws_lb" {
name = "${var.project_name}-Internal-NLB"
internal = true
load_balancer_type = "network"
subnets = aws_subnet.spoke_1_external_subnet.*.id
tags = {
Environment = "${var.project_name}-Internal_NLB"
x-chkp-forwarding = "TCP-${var.app_1_high_port}-80"
x-chkp-management = var.template_management_server_name
x-chkp-template = var.inbound_configuration_template_name
}
}
resource "aws_lb_listener" "internal_lb_listener" {
load_balancer_arn = aws_lb.internal_aws_lb.arn
port = 80
protocol = "TCP"
default_action {
target_group_arn = aws_lb_target_group.internal_lb_target_group.arn
type = "forward"
}
}
resource "aws_lb_target_group" "internal_lb_target_group" {
name = "${var.project_name}-Int-NLB-TG"
port = "80"
protocol = "TCP"
vpc_id = aws_vpc.spoke_1_vpc.id
tags = {
name = "${var.project_name}-Int-NLB-TG"
}
}
resource "aws_lb_target_group_attachment" "internal_lb_target_group_attachment" {
count = length(aws_instance.spoke_1_instance)
target_group_arn = aws_lb_target_group.internal_lb_target_group.arn
target_id = element(aws_instance.spoke_1_instance.*.id, count.index)
port = 80
}