-
Notifications
You must be signed in to change notification settings - Fork 2
/
loadbalancer.tf
66 lines (57 loc) · 2.29 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
# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
resource "oci_load_balancer_load_balancer" "dotnet_lb" {
compartment_id = var.compartment_ocid
display_name = "DotNet-${random_string.deploy_id.result}"
shape = var.lb_shape
subnet_ids = [oci_core_subnet.dotnet_lb_subnet.id]
is_private = "false"
freeform_tags = local.common_tags
}
resource "oci_load_balancer_backend_set" "dotnet_bes" {
name = "dotnet-${random_string.deploy_id.result}"
load_balancer_id = oci_load_balancer_load_balancer.dotnet_lb.id
policy = "IP_HASH"
health_checker {
port = local.app_port_number
protocol = "HTTP"
response_body_regex = ".*"
url_path = "/"
return_code = 200
interval_ms = 5000
timeout_in_millis = 2000
retries = 10
}
}
resource "oci_load_balancer_backend" "dotnet-be" {
load_balancer_id = oci_load_balancer_load_balancer.dotnet_lb.id
backendset_name = oci_load_balancer_backend_set.dotnet_bes.name
ip_address = element(oci_core_instance.app_instance.*.private_ip, count.index)
port = local.app_port_number
backup = false
drain = false
offline = false
weight = 1
count = var.num_instances
}
resource "oci_load_balancer_listener" "dotnet_listener_80" {
load_balancer_id = oci_load_balancer_load_balancer.dotnet_lb.id
default_backend_set_name = oci_load_balancer_backend_set.dotnet_bes.name
name = "dotnet-${random_string.deploy_id.result}-80"
port = local.http_port_number
protocol = "HTTP"
connection_configuration {
idle_timeout_in_seconds = "30"
}
}
resource "oci_load_balancer_listener" "dotnet_listener_443" {
load_balancer_id = oci_load_balancer_load_balancer.dotnet_lb.id
default_backend_set_name = oci_load_balancer_backend_set.dotnet_bes.name
name = "dotnet-${random_string.deploy_id.result}-443"
port = local.https_port_number
protocol = "HTTP"
connection_configuration {
idle_timeout_in_seconds = "30"
}
}