-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-balancer.tf
80 lines (69 loc) · 1.85 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
70
71
72
73
74
75
76
77
78
79
80
// Internal NLB for CR
resource "yandex_lb_network_load_balancer" "cr_nlb" {
folder_id = var.folder_id
name = "cr-nlb"
type = "internal"
listener {
name = "https-listener"
port = 443
target_port = 4434
internal_address_spec {
subnet_id = yandex_vpc_subnet.nat_vm_subnets[0].id
address = cidrhost(yandex_vpc_subnet.nat_vm_subnets[0].v4_cidr_blocks[0], 100)
}
}
attached_target_group {
target_group_id = yandex_lb_target_group.cr_nat_group.id
healthcheck {
name = "healthcheck"
timeout = 2
interval = 3
unhealthy_threshold = 3
healthy_threshold = 3
tcp_options {
port = 4434
}
}
}
}
// target group with NAT instances
resource "yandex_lb_target_group" "cr_nat_group" {
folder_id = var.folder_id
name = "cr-nat-group"
dynamic "target" {
for_each = yandex_compute_instance.nat_vm
content {
subnet_id = target.value.network_interface.0.subnet_id
address = target.value.network_interface.0.ip_address
}
}
}
// Internal NLB for S3
resource "yandex_lb_network_load_balancer" "s3_nlb" {
folder_id = var.folder_id
name = "s3-nlb"
type = "internal"
depends_on = [yandex_lb_network_load_balancer.cr_nlb]
listener {
name = "https-listener"
port = 443
target_port = 4435
internal_address_spec {
subnet_id = yandex_vpc_subnet.nat_vm_subnets[0].id
address = cidrhost(yandex_vpc_subnet.nat_vm_subnets[0].v4_cidr_blocks[0], 200)
}
}
attached_target_group {
target_group_id = yandex_lb_target_group.cr_nat_group.id
healthcheck {
name = "healthcheck"
timeout = 2
interval = 3
unhealthy_threshold = 3
healthy_threshold = 3
tcp_options {
port = 4435
}
}
}
}