forked from garutilorenzo/oracle-cloud-terraform-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lb.tf
50 lines (41 loc) · 1.71 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
resource "oci_network_load_balancer_network_load_balancer" "test_network_load_balancer" {
depends_on = [
oci_core_instance_pool.ubuntu_instance_pool,
]
compartment_id = var.compartment_ocid
display_name = "Test Network LB"
subnet_id = oci_core_subnet.oci_core_subnet11.id
is_private = false
is_preserve_source_destination = false
freeform_tags = {
"${var.tutorial_tag_key}" = "${var.tutorial_tag_value}"
}
}
resource "oci_network_load_balancer_listener" "test_listener" {
#Required
default_backend_set_name = oci_network_load_balancer_backend_set.test_backend_set.name
name = "LB test listener"
network_load_balancer_id = oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id
port = 80
protocol = "TCP"
}
resource "oci_network_load_balancer_backend_set" "test_backend_set" {
health_checker {
protocol = "TCP"
port = 80
}
name = "Backend set test"
network_load_balancer_id = oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id
policy = "FIVE_TUPLE"
is_preserve_source = true
}
resource "oci_network_load_balancer_backend" "test_backend" {
depends_on = [
oci_core_instance_pool.ubuntu_instance_pool,
]
count = var.instance_pool_size
backend_set_name = oci_network_load_balancer_backend_set.test_backend_set.name
network_load_balancer_id = oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id
port = 80
target_id = data.oci_core_instance_pool_instances.ubuntu_instance_pool_instances.instances[count.index].id
}