-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlb.tf
116 lines (100 loc) · 2.61 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
module "load_balancer" {
source = "GoogleCloudPlatform/lb-http/google//modules/serverless_negs"
version = "11.1.0"
project = var.project_id
name = "gateway-${var.instance_name}"
ssl = true
ssl_policy = google_compute_ssl_policy.main.id
random_certificate_suffix = true # In case the domain changes
managed_ssl_certificate_domains = [
var.pohttp_server_domain,
var.poweb_server_domain,
var.cogrpc_server_domain,
]
create_url_map = false
url_map = google_compute_url_map.main.self_link
backends = {
pohttp = {
description = "PoHTTP"
groups = [
{
group = google_compute_region_network_endpoint_group.pohttp.id
}
]
enable_cdn = false
iap_config = {
enable = false
}
log_config = {
enable = true
sample_rate = 1.0
}
}
poweb = {
description = "PoWeb"
groups = [
{
group = google_compute_region_network_endpoint_group.poweb.id
}
]
enable_cdn = false
iap_config = {
enable = false
}
log_config = {
enable = true
sample_rate = 1.0
}
}
cogrpc = {
description = "CogRPC"
groups = [
{
group = google_compute_region_network_endpoint_group.cogrpc.id
}
]
enable_cdn = false
iap_config = {
enable = false
}
log_config = {
enable = true
sample_rate = 1.0
}
}
}
http_forward = false
}
resource "google_compute_url_map" "main" {
name = "gateway-${var.instance_name}"
default_service = module.load_balancer.backend_services["pohttp"].self_link
host_rule {
hosts = [replace(var.pohttp_server_domain, "/\\.$/", "")]
path_matcher = "pohttp"
}
path_matcher {
name = "pohttp"
default_service = module.load_balancer.backend_services["pohttp"].self_link
}
host_rule {
hosts = [replace(var.poweb_server_domain, "/\\.$/", "")]
path_matcher = "poweb"
}
path_matcher {
name = "poweb"
default_service = module.load_balancer.backend_services["poweb"].self_link
}
host_rule {
hosts = [replace(var.cogrpc_server_domain, "/\\.$/", "")]
path_matcher = "cogrpc"
}
path_matcher {
name = "cogrpc"
default_service = module.load_balancer.backend_services["cogrpc"].self_link
}
}
resource "google_compute_ssl_policy" "main" {
name = "gateway-${var.instance_name}"
profile = "MODERN"
min_tls_version = "TLS_1_2"
}