-
Notifications
You must be signed in to change notification settings - Fork 2
/
loadbalancer.tf
67 lines (56 loc) · 1.71 KB
/
loadbalancer.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
resource "aws_lb" "neo4j_lb" {
name = "${var.env_prefix}-nlb"
internal = false
load_balancer_type = "network"
subnets = [for subnet in aws_subnet.neo4j_public_subnet : subnet.id]
tags = {
"Name" = "${var.env_prefix}-nlb"
"Terraform" = true
}
lifecycle {
ignore_changes = [
]
}
}
resource "aws_lb_listener" "neo4j_listener_http" {
load_balancer_arn = aws_lb.neo4j_lb.arn
port = "7474"
protocol = "TCP"
default_action {
target_group_arn = aws_lb_target_group.neo4j_http_lb_tg.arn
type = "forward"
}
}
resource "aws_lb_listener" "neo4j_listener_bolt" {
load_balancer_arn = aws_lb.neo4j_lb.arn
port = "7687"
protocol = "TCP"
default_action {
target_group_arn = aws_lb_target_group.neo4j_bolt_lb_tg.arn
type = "forward"
}
}
resource "aws_lb_target_group" "neo4j_http_lb_tg" {
name = "${var.env_prefix}-http-tg"
port = 7474
protocol = "TCP"
vpc_id = aws_vpc.neo4j_vpc.id
}
resource "aws_lb_target_group" "neo4j_bolt_lb_tg" {
name = "${var.env_prefix}-bolt-tg"
port = 7687
protocol = "TCP"
vpc_id = aws_vpc.neo4j_vpc.id
}
resource "aws_lb_target_group_attachment" "neo4j_http_lb_tg_attachment" {
count = var.node_count
target_group_arn = aws_lb_target_group.neo4j_http_lb_tg.arn
target_id = aws_instance.neo4j_instance[count.index].id
port = 7474
}
resource "aws_lb_target_group_attachment" "neo4j_bolt_lb_tg_attachment" {
count = var.node_count
target_group_arn = aws_lb_target_group.neo4j_bolt_lb_tg.arn
target_id = aws_instance.neo4j_instance[count.index].id
port = 7687
}