-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlb_public.tf
105 lines (94 loc) · 3.29 KB
/
lb_public.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
96
97
98
99
100
101
102
103
104
105
resource "oci_load_balancer_load_balancer" "cluster_load_balancer" {
compartment_id = var.oci_tenancy_ocid
display_name = "cluster-load-balancer"
shape = "flexible"
subnet_ids = [
oci_core_subnet.cluster_subnet.id
]
ip_mode = "IPV4"
network_security_group_ids = [
oci_core_network_security_group.permit_https.id
]
shape_details {
maximum_bandwidth_in_mbps = 10
minimum_bandwidth_in_mbps = 10
}
}
resource "oci_load_balancer_listener" "https_listener" {
default_backend_set_name = oci_load_balancer_backend_set.https_backend_set.name
load_balancer_id = oci_load_balancer_load_balancer.cluster_load_balancer.id
name = "https-listener"
port = 443
protocol = "TCP"
}
resource "oci_load_balancer_backend_set" "https_backend_set" {
health_checker {
protocol = "TCP"
port = 443
}
load_balancer_id = oci_load_balancer_load_balancer.cluster_load_balancer.id
name = "https-backend-set"
policy = "ROUND_ROBIN"
}
resource "oci_load_balancer_backend" "https_backend" {
count = length(local.cluster_nodes)
backendset_name = oci_load_balancer_backend_set.https_backend_set.name
ip_address = local.cluster_nodes[count.index].private_ip
load_balancer_id = oci_load_balancer_load_balancer.cluster_load_balancer.id
port = 443
}
resource "oci_load_balancer_listener" "http_listener" {
default_backend_set_name = oci_load_balancer_backend_set.http_backend_set.name
load_balancer_id = oci_load_balancer_load_balancer.cluster_load_balancer.id
name = "http-listener"
port = 80
protocol = "TCP"
}
resource "oci_load_balancer_backend_set" "http_backend_set" {
health_checker {
protocol = "TCP"
port = 80
}
load_balancer_id = oci_load_balancer_load_balancer.cluster_load_balancer.id
name = "http-backend-set"
policy = "ROUND_ROBIN"
}
resource "oci_load_balancer_backend" "http_backend" {
count = length(local.cluster_nodes)
backendset_name = oci_load_balancer_backend_set.http_backend_set.name
ip_address = local.cluster_nodes[count.index].private_ip
load_balancer_id = oci_load_balancer_load_balancer.cluster_load_balancer.id
port = 80
}
# Network Security Group
resource "oci_core_network_security_group" "permit_https" {
compartment_id = var.oci_tenancy_ocid
vcn_id = oci_core_vcn.cluster_vcn.id
display_name = "Permit HTTP/S"
}
resource "oci_core_network_security_group_security_rule" "permit_https" {
network_security_group_id = oci_core_network_security_group.permit_https.id
protocol = "6" // TCP
source = "0.0.0.0/0"
source_type = "CIDR_BLOCK"
tcp_options {
destination_port_range {
max = 443
min = 443
}
}
direction = "INGRESS"
}
resource "oci_core_network_security_group_security_rule" "permit_http" {
network_security_group_id = oci_core_network_security_group.permit_https.id
protocol = "6" // TCP
source = "0.0.0.0/0"
source_type = "CIDR_BLOCK"
tcp_options {
destination_port_range {
max = 80
min = 80
}
}
direction = "INGRESS"
}