-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload_balancer.tf
69 lines (59 loc) · 1.69 KB
/
load_balancer.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
resource "aws_lb" "loadbalancer" {
name = "${local.config.component_name}-lb"
internal = var.load_balancer_internal
load_balancer_type = "network"
subnets = var.subnet_ids
enable_cross_zone_load_balancing = true
}
resource "aws_lb_target_group" "http" {
name = "${local.config.component_name}-target-HTTP"
port = 4200
protocol = "TCP"
target_type = "ip"
vpc_id = var.vpc_id
}
resource "aws_lb_target_group" "postgresql" {
name = "${local.config.component_name}-PostgreSQL"
port = 5432
protocol = "TCP"
target_type = "ip"
vpc_id = var.vpc_id
stickiness {
type = "source_ip"
enabled = false
}
}
resource "aws_lb_target_group" "jmx" {
name = "${local.config.component_name}-target-JMX"
port = 8080
protocol = "TCP"
target_type = "ip"
vpc_id = var.vpc_id
}
resource "aws_lb_listener" "http" {
load_balancer_arn = aws_lb.loadbalancer.arn
port = 4200
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.http.arn
}
}
resource "aws_lb_listener" "postgresql" {
load_balancer_arn = aws_lb.loadbalancer.arn
port = 5432
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.postgresql.arn
}
}
resource "aws_lb_listener" "jmx" {
load_balancer_arn = aws_lb.loadbalancer.arn
port = 8080
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.jmx.arn
}
}