This repository has been archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
lb.tf
96 lines (82 loc) · 3 KB
/
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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
## Copyright © 2020, Oracle and/or its affiliates.
## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
resource "oci_load_balancer_load_balancer" "lb1" {
shape = var.lb_shape
dynamic "shape_details" {
for_each = local.is_flexible_lb_shape ? [1] : []
content {
minimum_bandwidth_in_mbps = var.flex_lb_min_shape
maximum_bandwidth_in_mbps = var.flex_lb_max_shape
}
}
compartment_id = var.compartment_ocid
display_name = "${var.instance_name}-lb1"
subnet_ids = [
oci_core_subnet.Subnet.id,
]
defined_tags = {"${oci_identity_tag_namespace.ArchitectureCenterTagNamespace.name}.${oci_identity_tag.ArchitectureCenterTag.name}" = var.release }
}
resource "oci_load_balancer_listener" "lb-listener1" {
load_balancer_id = oci_load_balancer_load_balancer.lb1.id
name = "tcp26257"
default_backend_set_name = oci_load_balancer_backend_set.lb-bes1.name
port = 26257
protocol = "TCP"
connection_configuration {
idle_timeout_in_seconds = "2"
}
}
resource "oci_load_balancer_backend_set" "lb-bes1" {
name = "lb-bes1"
load_balancer_id = oci_load_balancer_load_balancer.lb1.id
policy = "ROUND_ROBIN"
health_checker {
port = "8080"
protocol = "HTTP"
response_body_regex = ".*"
url_path = "/health?ready=1"
}
}
resource "oci_load_balancer_backend" "lb-be1" {
load_balancer_id = oci_load_balancer_load_balancer.lb1.id
backendset_name = oci_load_balancer_backend_set.lb-bes1.name
count = var.instance_count
ip_address = oci_core_instance.CockroachDBInstance[count.index].private_ip
port = 26257
backup = false
drain = false
offline = false
weight = 1
}
resource "oci_load_balancer_listener" "lb-listener2" {
load_balancer_id = oci_load_balancer_load_balancer.lb1.id
name = "http8080"
default_backend_set_name = oci_load_balancer_backend_set.lb-bes2.name
port = 8080
protocol = "HTTP"
connection_configuration {
idle_timeout_in_seconds = "2"
}
}
resource "oci_load_balancer_backend_set" "lb-bes2" {
name = "lb-bes2"
load_balancer_id = oci_load_balancer_load_balancer.lb1.id
policy = "ROUND_ROBIN"
health_checker {
port = "8080"
protocol = "HTTP"
response_body_regex = ".*"
url_path = "/health?ready=1"
}
}
resource "oci_load_balancer_backend" "lb-be2" {
load_balancer_id = oci_load_balancer_load_balancer.lb1.id
backendset_name = oci_load_balancer_backend_set.lb-bes2.name
count = var.instance_count
ip_address = oci_core_instance.CockroachDBInstance[count.index].private_ip
port = 8080
backup = false
drain = false
offline = false
weight = 1
}