2020-08-15 01:12:43 -07:00
|
|
|
/**
|
2022-01-01 06:52:31 -08:00
|
|
|
* Copyright 2022 Google LLC
|
2020-08-15 01:12:43 -07:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
module "gw" {
|
2022-01-10 06:09:38 -08:00
|
|
|
source = "../../../modules/compute-vm"
|
2021-10-04 01:46:44 -07:00
|
|
|
for_each = local.zones
|
2020-08-15 01:12:43 -07:00
|
|
|
project_id = module.project.project_id
|
2021-10-04 01:46:44 -07:00
|
|
|
zone = each.value
|
2022-11-23 02:09:00 -08:00
|
|
|
name = "${var.prefix}-gw-${each.key}"
|
2020-08-15 01:12:43 -07:00
|
|
|
instance_type = "f1-micro"
|
|
|
|
|
|
|
|
boot_disk = {
|
|
|
|
image = "projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts",
|
|
|
|
type = "pd-ssd",
|
|
|
|
size = 10
|
|
|
|
}
|
|
|
|
|
|
|
|
network_interfaces = [
|
|
|
|
{
|
|
|
|
network = module.vpc-left.self_link
|
|
|
|
subnetwork = values(module.vpc-left.subnet_self_links)[0],
|
|
|
|
nat = false,
|
2021-07-25 08:17:45 -07:00
|
|
|
addresses = null
|
2020-08-15 01:12:43 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
network = module.vpc-right.self_link
|
|
|
|
subnetwork = values(module.vpc-right.subnet_self_links)[0],
|
|
|
|
nat = false,
|
2021-07-25 08:17:45 -07:00
|
|
|
addresses = null
|
2020-08-15 01:12:43 -07:00
|
|
|
}
|
|
|
|
]
|
|
|
|
tags = ["ssh"]
|
|
|
|
can_ip_forward = true
|
|
|
|
metadata = {
|
|
|
|
user-data = templatefile("${path.module}/assets/gw.yaml", {
|
|
|
|
gw_right = cidrhost(var.ip_ranges.right, 1)
|
|
|
|
ip_cidr_right = var.ip_ranges.right
|
|
|
|
})
|
|
|
|
}
|
|
|
|
service_account = try(
|
2022-11-23 02:09:00 -08:00
|
|
|
module.service-accounts.emails["${var.prefix}-gce-vm"], null
|
2020-08-15 01:12:43 -07:00
|
|
|
)
|
|
|
|
service_account_scopes = ["https://www.googleapis.com/auth/cloud-platform"]
|
|
|
|
group = { named_ports = null }
|
|
|
|
}
|
|
|
|
|
|
|
|
module "ilb-left" {
|
2022-01-10 06:09:38 -08:00
|
|
|
source = "../../../modules/net-ilb"
|
2020-08-15 01:12:43 -07:00
|
|
|
project_id = module.project.project_id
|
|
|
|
region = var.region
|
2022-11-23 02:09:00 -08:00
|
|
|
name = "${var.prefix}-ilb-left"
|
2022-11-02 10:05:20 -07:00
|
|
|
vpc_config = {
|
|
|
|
network = module.vpc-left.self_link
|
|
|
|
subnetwork = values(module.vpc-left.subnet_self_links)[0]
|
|
|
|
}
|
|
|
|
address = local.addresses.ilb-left
|
|
|
|
backend_service_config = {
|
|
|
|
session_affinity = var.ilb_session_affinity
|
2020-08-15 01:12:43 -07:00
|
|
|
}
|
2021-10-04 01:46:44 -07:00
|
|
|
backends = [for z, mod in module.gw : {
|
2022-11-02 10:05:20 -07:00
|
|
|
group = mod.group.self_link
|
2020-08-15 01:12:43 -07:00
|
|
|
}]
|
|
|
|
health_check_config = {
|
2022-11-02 10:05:20 -07:00
|
|
|
enable_logging = true
|
|
|
|
tcp = {
|
|
|
|
port = 22
|
|
|
|
}
|
2020-08-15 01:12:43 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module "ilb-right" {
|
2022-01-10 06:09:38 -08:00
|
|
|
source = "../../../modules/net-ilb"
|
2020-08-15 01:12:43 -07:00
|
|
|
project_id = module.project.project_id
|
|
|
|
region = var.region
|
2022-11-23 02:09:00 -08:00
|
|
|
name = "${var.prefix}-ilb-right"
|
2022-11-02 10:05:20 -07:00
|
|
|
vpc_config = {
|
|
|
|
network = module.vpc-right.self_link
|
|
|
|
subnetwork = values(module.vpc-right.subnet_self_links)[0]
|
|
|
|
}
|
|
|
|
address = local.addresses.ilb-right
|
|
|
|
backend_service_config = {
|
|
|
|
session_affinity = var.ilb_session_affinity
|
2020-08-15 01:12:43 -07:00
|
|
|
}
|
2021-10-04 01:46:44 -07:00
|
|
|
backends = [for z, mod in module.gw : {
|
2022-11-02 10:05:20 -07:00
|
|
|
group = mod.group.self_link
|
2020-08-15 01:12:43 -07:00
|
|
|
}]
|
|
|
|
health_check_config = {
|
2022-11-02 10:05:20 -07:00
|
|
|
enable_logging = true
|
|
|
|
tcp = {
|
|
|
|
port = 22
|
|
|
|
}
|
2020-08-15 01:12:43 -07:00
|
|
|
}
|
|
|
|
}
|