forked from apigee/terraform-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
89 lines (85 loc) · 2.63 KB
/
main.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
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
locals {
bridge_name = var.name == null ? "apigee-${var.region}" : var.name
}
module "bridge-template" {
source = "github.com/terraform-google-modules/cloud-foundation-fabric//modules/compute-vm?ref=v16.0.0"
project_id = var.project_id
name = local.bridge_name
zone = "${var.region}-b"
tags = var.network_tags
instance_type = var.machine_type
network_interfaces = [{
network = var.network,
subnetwork = var.subnet
nat = false
addresses = null
alias_ips = null
}]
boot_disk = {
image = "debian-cloud/debian-11"
type = "pd-standard"
size = 20
}
create_template = true
metadata = {
ENDPOINT = var.endpoint_ip
startup-script-url = "gs://apigee-5g-saas/apigee-envoy-proxy-release/latest/conf/startup-script.sh"
}
service_account_create = true
service_account_scopes = ["cloud-platform"]
}
module "bridge-mig" {
source = "github.com/terraform-google-modules/cloud-foundation-fabric//modules/compute-mig?ref=v16.0.0"
project_id = var.project_id
location = var.region
regional = true
name = local.bridge_name
target_size = var.target_size
autoscaler_config = var.autoscaler_config
default_version = {
instance_template = module.bridge-template.template.self_link
name = "default"
}
named_ports = {
https = 443
}
auto_healing_policies = {
health_check = module.bridge-mig.health_check.self_link
initial_delay_sec = 30
}
health_check_config = {
type = "https"
check = {
port = 443,
request_path = "/healthz/ingress"
}
config = {}
logging = false
}
}
resource "google_compute_firewall" "allow_glb_to_mig_bridge" {
name = "hc-${local.bridge_name}"
project = split("/", "google_compute_network.${var.network}")[1]
network = var.network
source_ranges = ["130.211.0.0/22", "35.191.0.0/16"]
target_tags = var.network_tags
allow {
protocol = "tcp"
ports = ["443"]
}
}