2022-02-03 11:30:56 -08:00
|
|
|
/**
|
|
|
|
* Copyright 2022 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 {
|
2022-02-15 23:07:58 -08:00
|
|
|
host_project_ids = {
|
2022-02-15 23:20:22 -08:00
|
|
|
dev-spoke-0 = module.dev-spoke-project.project_id
|
|
|
|
prod-landing = module.landing-project.project_id
|
|
|
|
prod-spoke-0 = module.prod-spoke-project.project_id
|
2022-02-15 23:07:58 -08:00
|
|
|
}
|
|
|
|
host_project_numbers = {
|
2022-02-15 23:20:22 -08:00
|
|
|
dev-spoke-0 = module.dev-spoke-project.number
|
|
|
|
prod-landing = module.landing-project.number
|
|
|
|
prod-spoke-0 = module.prod-spoke-project.number
|
2022-02-15 23:07:58 -08:00
|
|
|
}
|
2022-02-16 00:07:07 -08:00
|
|
|
tfvars = {
|
|
|
|
host_project_ids = local.host_project_ids
|
|
|
|
host_project_numbers = local.host_project_numbers
|
|
|
|
vpc_self_links = local.vpc_self_links
|
|
|
|
}
|
2022-02-15 23:07:58 -08:00
|
|
|
vpc_self_links = {
|
2022-02-15 23:20:22 -08:00
|
|
|
prod-landing-trusted = module.landing-trusted-vpc.self_link
|
|
|
|
prod-landing-untrusted = module.landing-untrusted-vpc.self_link
|
|
|
|
dev-spoke-0 = module.dev-spoke-vpc.self_link
|
|
|
|
prod-spoke-0 = module.prod-spoke-vpc.self_link
|
2022-02-03 11:30:56 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-15 23:07:58 -08:00
|
|
|
# optionally generate tfvars file for subsequent stages
|
|
|
|
|
2022-02-03 11:30:56 -08:00
|
|
|
resource "local_file" "tfvars" {
|
2022-02-15 23:07:58 -08:00
|
|
|
for_each = var.outputs_location == null ? {} : { 1 = 1 }
|
|
|
|
file_permission = "0644"
|
|
|
|
filename = "${pathexpand(var.outputs_location)}/tfvars/02-networking.auto.tfvars.json"
|
2022-02-16 00:07:07 -08:00
|
|
|
content = jsonencode(local.tfvars)
|
2022-02-03 11:30:56 -08:00
|
|
|
}
|
|
|
|
|
2022-02-15 23:07:58 -08:00
|
|
|
# outputs
|
2022-02-03 11:30:56 -08:00
|
|
|
|
2022-02-15 23:07:58 -08:00
|
|
|
output "host_project_ids" {
|
2022-02-03 11:30:56 -08:00
|
|
|
description = "Network project ids."
|
2022-02-15 23:07:58 -08:00
|
|
|
value = local.host_project_ids
|
2022-02-03 11:30:56 -08:00
|
|
|
}
|
|
|
|
|
2022-02-15 23:07:58 -08:00
|
|
|
output "host_project_numbers" {
|
2022-02-03 11:30:56 -08:00
|
|
|
description = "Network project numbers."
|
2022-02-15 23:07:58 -08:00
|
|
|
value = local.host_project_numbers
|
2022-02-03 11:30:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
output "shared_vpc_self_links" {
|
|
|
|
description = "Shared VPC host projects."
|
2022-02-15 23:07:58 -08:00
|
|
|
value = local.vpc_self_links
|
2022-02-03 11:30:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
output "vpn_gateway_endpoints" {
|
|
|
|
description = "External IP Addresses for the GCP VPN gateways."
|
|
|
|
value = {
|
|
|
|
onprem-ew1 = {
|
2022-02-28 03:27:27 -08:00
|
|
|
for v in module.landing-to-onprem-ew1-vpn[0].gateway.vpn_interfaces :
|
2022-02-03 11:30:56 -08:00
|
|
|
v.id => v.ip_address
|
|
|
|
}
|
|
|
|
onprem-ew4 = {
|
2022-02-28 03:27:27 -08:00
|
|
|
for v in module.landing-to-onprem-ew4-vpn[0].gateway.vpn_interfaces :
|
2022-02-03 11:30:56 -08:00
|
|
|
v.id => v.ip_address
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
output "tfvars" {
|
2022-02-15 23:07:58 -08:00
|
|
|
description = "Terraform variables file for the following stages."
|
2022-02-03 11:30:56 -08:00
|
|
|
sensitive = true
|
2022-02-16 00:07:07 -08:00
|
|
|
value = local.tfvars
|
2022-02-03 11:30:56 -08:00
|
|
|
}
|