diff --git a/blueprints/networking/glb-hybrid-neg-internal/README.md b/blueprints/networking/glb-hybrid-neg-internal/README.md index 635996e8ed..6ba1173119 100644 --- a/blueprints/networking/glb-hybrid-neg-internal/README.md +++ b/blueprints/networking/glb-hybrid-neg-internal/README.md @@ -72,11 +72,18 @@ At the moment, every time a user changes the configuration of a NEG, the NEG is | name | description | type | required | default | |---|---|:---:|:---:|:---:| | [prefix](variables.tf#L17) | Prefix used for resource names. | string | ✓ | | -| [projects_create](variables.tf#L26) | Parameters for the creation of the new project. | object({…}) | | null | -| [region_configs](variables.tf#L35) | The primary and secondary region parameters. | object({…}) | | {…} | -| [test_vms_behind_ilb](variables.tf#L59) | Whether there should be an ILB L4 in front of the test VMs in the spoke. | string | | "false" | -| [vpc_landing_trusted_config](variables.tf#L77) | The configuration of the landing trusted VPC | object({…}) | | {…} | -| [vpc_landing_untrusted_config](variables.tf#L65) | The configuration of the landing untrusted VPC | object({…}) | | {…} | -| [vpc_spoke_config](variables.tf#L89) | The configuration of the spoke-01 VPC | object({…}) | | {…} | +| [project_names](variables.tf#L26) | The project names. | object({…}) | | {…} | +| [projects_create](variables.tf#L38) | Parameters for the creation of the new project. | object({…}) | | null | +| [region_configs](variables.tf#L47) | The primary and secondary region parameters. | object({…}) | | {…} | +| [test_vms_behind_ilb](variables.tf#L71) | Whether there should be an ILB L4 in front of the test VMs in the spoke. | string | | "false" | +| [vpc_landing_trusted_config](variables.tf#L77) | The configuration of the landing trusted VPC. | object({…}) | | {…} | +| [vpc_landing_untrusted_config](variables.tf#L89) | The configuration of the landing untrusted VPC. | object({…}) | | {…} | +| [vpc_spoke_config](variables.tf#L101) | The configuration of the spoke-01 VPC. | object({…}) | | {…} | + +## Outputs + +| name | description | sensitive | +|---|---|:---:| +| [glb_ip_address](outputs.tf#L17) | Load balancer IP address. | | diff --git a/blueprints/networking/glb-hybrid-neg-internal/landing-hub.tf b/blueprints/networking/glb-hybrid-neg-internal/landing-hub.tf index 29ff2ca1ae..c039eb1a0b 100644 --- a/blueprints/networking/glb-hybrid-neg-internal/landing-hub.tf +++ b/blueprints/networking/glb-hybrid-neg-internal/landing-hub.tf @@ -19,12 +19,12 @@ ################################################################################ module "project_landing" { - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/project" + source = "../../../modules/project" billing_account = (var.projects_create != null ? var.projects_create.billing_account_id : null ) - name = "landing" + name = var.project_names.landing parent = (var.projects_create != null ? var.projects_create.parent : null @@ -46,7 +46,7 @@ module "project_landing" { ################################################################################ module "vpc_landing_untrusted" { - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-vpc" + source = "../../../modules/net-vpc" project_id = module.project_landing.project_id name = "landing-untrusted" @@ -78,7 +78,7 @@ module "vpc_landing_untrusted" { } module "vpc_landing_trusted" { - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-vpc" + source = "../../../modules/net-vpc" project_id = module.project_landing.project_id name = "landing-trusted" subnets = [ @@ -96,7 +96,7 @@ module "vpc_landing_trusted" { } module "firewall_landing_untrusted" { - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-vpc-firewall" + source = "../../../modules/net-vpc-firewall" project_id = module.project_landing.project_id network = module.vpc_landing_untrusted.name @@ -115,7 +115,7 @@ module "firewall_landing_untrusted" { module "nats_landing" { for_each = var.region_configs - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-cloudnat" + source = "../../../modules/net-cloudnat" project_id = module.project_landing.project_id region = each.value.region_name name = "nat-${each.value.region_name}" @@ -124,7 +124,7 @@ module "nats_landing" { module "nva_instance_templates" { for_each = var.region_configs - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/compute-vm" + source = "../../../modules/compute-vm" project_id = module.project_landing.project_id can_ip_forward = true create_template = true @@ -163,7 +163,7 @@ module "nva_instance_templates" { module "nva_migs" { for_each = var.region_configs - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/compute-mig" + source = "../../../modules/compute-mig" project_id = module.project_landing.project_id location = each.value.zone name = "nva-${each.value.region_name}" @@ -173,7 +173,7 @@ module "nva_migs" { module "nva_untrusted_ilbs" { for_each = var.region_configs - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-ilb" + source = "../../../modules/net-ilb" project_id = module.project_landing.project_id region = each.value.region_name name = "nva-ilb-${each.value.region_name}" @@ -193,7 +193,7 @@ module "nva_untrusted_ilbs" { } module "hybrid-glb" { - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-glb" + source = "../../../modules/net-glb" project_id = module.project_landing.project_id name = "hybrid-glb" backend_service_configs = { diff --git a/blueprints/networking/glb-hybrid-neg-internal/outputs.tf b/blueprints/networking/glb-hybrid-neg-internal/outputs.tf index 8190cc901e..7d8ce185ff 100644 --- a/blueprints/networking/glb-hybrid-neg-internal/outputs.tf +++ b/blueprints/networking/glb-hybrid-neg-internal/outputs.tf @@ -13,3 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +output "glb_ip_address" { + description = "Load balancer IP address." + value = module.hybrid-glb.address +} diff --git a/blueprints/networking/glb-hybrid-neg-internal/spoke.tf b/blueprints/networking/glb-hybrid-neg-internal/spoke.tf index d205c6332c..07b2ec4301 100644 --- a/blueprints/networking/glb-hybrid-neg-internal/spoke.tf +++ b/blueprints/networking/glb-hybrid-neg-internal/spoke.tf @@ -15,12 +15,12 @@ */ module "project_spoke_01" { - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/project" + source = "../../../modules/project" billing_account = (var.projects_create != null ? var.projects_create.billing_account_id : null ) - name = "spoke-01" + name = var.project_names.spoke_01 parent = (var.projects_create != null ? var.projects_create.parent : null @@ -37,7 +37,7 @@ module "project_spoke_01" { } module "vpc_spoke_01" { - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-vpc" + source = "../../../modules/net-vpc" project_id = module.project_spoke_01.project_id name = "spoke-01" subnets = [ @@ -59,7 +59,7 @@ module "vpc_spoke_01" { } module "firewall_spoke_01" { - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-vpc-firewall" + source = "../../../modules/net-vpc-firewall" project_id = module.project_spoke_01.project_id network = module.vpc_spoke_01.name @@ -80,7 +80,7 @@ module "firewall_spoke_01" { module "nats_spoke_01" { for_each = var.region_configs - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-cloudnat" + source = "../../../modules/net-cloudnat" name = "spoke-01-${each.value.region_name}" project_id = module.project_spoke_01.project_id region = each.value.region_name @@ -89,7 +89,7 @@ module "nats_spoke_01" { module "test_vms" { for_each = var.region_configs - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/compute-vm" + source = "../../../modules/compute-vm" name = "spoke-01-${each.value.region_name}" project_id = module.project_spoke_01.project_id create_template = var.test_vms_behind_ilb @@ -114,7 +114,7 @@ module "test_vms" { module "test_vm_migs" { for_each = var.test_vms_behind_ilb ? var.region_configs : {} - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/compute-mig" + source = "../../../modules/compute-mig" project_id = module.project_spoke_01.project_id location = each.value.zone name = "test-vm-${each.value.region_name}" @@ -124,7 +124,7 @@ module "test_vm_migs" { module "test_vm_ilbs" { for_each = var.test_vms_behind_ilb ? var.region_configs : {} - source = "git::https://github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-ilb" + source = "../../../modules/net-ilb" project_id = module.project_spoke_01.project_id region = each.value.region_name name = "test-vm-ilb-${each.value.region_name}" diff --git a/blueprints/networking/glb-hybrid-neg-internal/variables.tf b/blueprints/networking/glb-hybrid-neg-internal/variables.tf index 9795c31049..fd3aff7d42 100644 --- a/blueprints/networking/glb-hybrid-neg-internal/variables.tf +++ b/blueprints/networking/glb-hybrid-neg-internal/variables.tf @@ -23,6 +23,18 @@ variable "prefix" { } } +variable "project_names" { + description = "The project names." + type = object({ + landing = string + spoke_01 = string + }) + default = { + landing = "landing" + spoke_01 = "spoke-01" + } +} + variable "projects_create" { description = "Parameters for the creation of the new project." type = object({ @@ -62,32 +74,32 @@ variable "test_vms_behind_ilb" { default = false } -variable "vpc_landing_untrusted_config" { - description = "The configuration of the landing untrusted VPC" +variable "vpc_landing_trusted_config" { + description = "The configuration of the landing trusted VPC." type = object({ r1_cidr = string r2_cidr = string }) default = { - r1_cidr = "192.168.1.0/24", - r2_cidr = "192.168.2.0/24" + r1_cidr = "192.168.11.0/24", + r2_cidr = "192.168.22.0/24" } } -variable "vpc_landing_trusted_config" { - description = "The configuration of the landing trusted VPC" +variable "vpc_landing_untrusted_config" { + description = "The configuration of the landing untrusted VPC." type = object({ r1_cidr = string r2_cidr = string }) default = { - r1_cidr = "192.168.11.0/24", - r2_cidr = "192.168.22.0/24" + r1_cidr = "192.168.1.0/24", + r2_cidr = "192.168.2.0/24" } } variable "vpc_spoke_config" { - description = "The configuration of the spoke-01 VPC" + description = "The configuration of the spoke-01 VPC." type = object({ r1_cidr = string r2_cidr = string diff --git a/tests/blueprints/networking/glb-hybrid-neg-internal/__init__.py b/tests/blueprints/networking/glb-hybrid-neg-internal/__init__.py new file mode 100644 index 0000000000..7ba50f9339 --- /dev/null +++ b/tests/blueprints/networking/glb-hybrid-neg-internal/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2023 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. diff --git a/tests/blueprints/networking/glb-hybrid-neg-internal/fixture/main.tf b/tests/blueprints/networking/glb-hybrid-neg-internal/fixture/main.tf new file mode 100644 index 0000000000..d52d039dec --- /dev/null +++ b/tests/blueprints/networking/glb-hybrid-neg-internal/fixture/main.tf @@ -0,0 +1,20 @@ +# Copyright 2023 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 +# +# https://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 "test" { + source = "../../../../../blueprints/networking/glb-hybrid-neg-internal" + prefix = var.prefix + projects_create = var.projects_create + project_names = var.project_names +} diff --git a/tests/blueprints/networking/glb-hybrid-neg-internal/fixture/variables.tf b/tests/blueprints/networking/glb-hybrid-neg-internal/fixture/variables.tf new file mode 100644 index 0000000000..b7fea04cca --- /dev/null +++ b/tests/blueprints/networking/glb-hybrid-neg-internal/fixture/variables.tf @@ -0,0 +1,111 @@ +/** + * Copyright 2023 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. + */ + +variable "prefix" { + description = "Prefix used for resource names." + type = string + default = "test" +} + +variable "projects_create" { + description = "Parameters for the creation of the new project." + type = object({ + billing_account_id = string + parent = string + }) + default = { + billing_account_id = "123456789" + parent = "organizations/123456789" + } +} + +variable "project_names" { + description = "The project names." + type = object({ + landing = string + spoke_01 = string + }) + default = { + landing = "landing" + spoke_01 = "spoke-01" + } +} + +variable "region_configs" { + description = "The primary and secondary region parameters." + type = object({ + r1 = object({ + region_name = string + zone = string + }) + r2 = object({ + region_name = string + zone = string + }) + }) + default = { + r1 = { + region_name = "europe-west1" + zone = "europe-west1-b" + } + r2 = { + region_name = "europe-west2" + zone = "europe-west2-b" + } + } +} + +variable "test_vms_behind_ilb" { + description = "Whether there should be an ILB L4 in front of the test VMs in the spoke." + type = string + default = false +} + +variable "vpc_landing_untrusted_config" { + description = "The configuration of the landing untrusted VPC" + type = object({ + r1_cidr = string + r2_cidr = string + }) + default = { + r1_cidr = "192.168.1.0/24", + r2_cidr = "192.168.2.0/24" + } +} + +variable "vpc_landing_trusted_config" { + description = "The configuration of the landing trusted VPC" + type = object({ + r1_cidr = string + r2_cidr = string + }) + default = { + r1_cidr = "192.168.11.0/24", + r2_cidr = "192.168.22.0/24" + } +} + +variable "vpc_spoke_config" { + description = "The configuration of the spoke-01 VPC" + type = object({ + r1_cidr = string + r2_cidr = string + }) + default = { + r1_cidr = "192.168.101.0/24", + r2_cidr = "192.168.102.0/24" + } +} diff --git a/tests/blueprints/networking/glb-hybrid-neg-internal/test_plan.py b/tests/blueprints/networking/glb-hybrid-neg-internal/test_plan.py new file mode 100644 index 0000000000..998a058736 --- /dev/null +++ b/tests/blueprints/networking/glb-hybrid-neg-internal/test_plan.py @@ -0,0 +1,19 @@ +# Copyright 2023 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. + +def test_resources(e2e_plan_runner): + "Test that plan works and the numbers of resources is as expected." + modules, resources = e2e_plan_runner() + assert len(modules) == 20 + assert len(resources) == 64