Skip to content

Commit

Permalink
Fixes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Prete committed Feb 11, 2023
1 parent 3d20e49 commit dd6edd8
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 33 deletions.
19 changes: 13 additions & 6 deletions blueprints/networking/glb-hybrid-neg-internal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | <code>string</code> || |
| [projects_create](variables.tf#L26) | Parameters for the creation of the new project. | <code title="object&#40;&#123;&#10; billing_account_id &#61; string&#10; parent &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [region_configs](variables.tf#L35) | The primary and secondary region parameters. | <code title="object&#40;&#123;&#10; r1 &#61; object&#40;&#123;&#10; region_name &#61; string&#10; zone &#61; string&#10; &#125;&#41;&#10; r2 &#61; object&#40;&#123;&#10; region_name &#61; string&#10; zone &#61; string&#10; &#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; r1 &#61; &#123;&#10; region_name &#61; &#34;europe-west1&#34;&#10; zone &#61; &#34;europe-west1-b&#34;&#10; &#125;&#10; r2 &#61; &#123;&#10; region_name &#61; &#34;europe-west2&#34;&#10; zone &#61; &#34;europe-west2-b&#34;&#10; &#125;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [test_vms_behind_ilb](variables.tf#L59) | Whether there should be an ILB L4 in front of the test VMs in the spoke. | <code>string</code> | | <code>&#34;false&#34;</code> |
| [vpc_landing_trusted_config](variables.tf#L77) | The configuration of the landing trusted VPC | <code title="object&#40;&#123;&#10; r1_cidr &#61; string&#10; r2_cidr &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; r1_cidr &#61; &#34;192.168.11.0&#47;24&#34;,&#10; r2_cidr &#61; &#34;192.168.22.0&#47;24&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [vpc_landing_untrusted_config](variables.tf#L65) | The configuration of the landing untrusted VPC | <code title="object&#40;&#123;&#10; r1_cidr &#61; string&#10; r2_cidr &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; r1_cidr &#61; &#34;192.168.1.0&#47;24&#34;,&#10; r2_cidr &#61; &#34;192.168.2.0&#47;24&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [vpc_spoke_config](variables.tf#L89) | The configuration of the spoke-01 VPC | <code title="object&#40;&#123;&#10; r1_cidr &#61; string&#10; r2_cidr &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; r1_cidr &#61; &#34;192.168.101.0&#47;24&#34;,&#10; r2_cidr &#61; &#34;192.168.102.0&#47;24&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [project_names](variables.tf#L26) | The project names. | <code title="object&#40;&#123;&#10; landing &#61; string&#10; spoke_01 &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; landing &#61; &#34;landing&#34;&#10; spoke_01 &#61; &#34;spoke-01&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [projects_create](variables.tf#L38) | Parameters for the creation of the new project. | <code title="object&#40;&#123;&#10; billing_account_id &#61; string&#10; parent &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [region_configs](variables.tf#L47) | The primary and secondary region parameters. | <code title="object&#40;&#123;&#10; r1 &#61; object&#40;&#123;&#10; region_name &#61; string&#10; zone &#61; string&#10; &#125;&#41;&#10; r2 &#61; object&#40;&#123;&#10; region_name &#61; string&#10; zone &#61; string&#10; &#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; r1 &#61; &#123;&#10; region_name &#61; &#34;europe-west1&#34;&#10; zone &#61; &#34;europe-west1-b&#34;&#10; &#125;&#10; r2 &#61; &#123;&#10; region_name &#61; &#34;europe-west2&#34;&#10; zone &#61; &#34;europe-west2-b&#34;&#10; &#125;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [test_vms_behind_ilb](variables.tf#L71) | Whether there should be an ILB L4 in front of the test VMs in the spoke. | <code>string</code> | | <code>&#34;false&#34;</code> |
| [vpc_landing_trusted_config](variables.tf#L77) | The configuration of the landing trusted VPC. | <code title="object&#40;&#123;&#10; r1_cidr &#61; string&#10; r2_cidr &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; r1_cidr &#61; &#34;192.168.11.0&#47;24&#34;,&#10; r2_cidr &#61; &#34;192.168.22.0&#47;24&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [vpc_landing_untrusted_config](variables.tf#L89) | The configuration of the landing untrusted VPC. | <code title="object&#40;&#123;&#10; r1_cidr &#61; string&#10; r2_cidr &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; r1_cidr &#61; &#34;192.168.1.0&#47;24&#34;,&#10; r2_cidr &#61; &#34;192.168.2.0&#47;24&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [vpc_spoke_config](variables.tf#L101) | The configuration of the spoke-01 VPC. | <code title="object&#40;&#123;&#10; r1_cidr &#61; string&#10; r2_cidr &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; r1_cidr &#61; &#34;192.168.101.0&#47;24&#34;,&#10; r2_cidr &#61; &#34;192.168.102.0&#47;24&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |

## Outputs

| name | description | sensitive |
|---|---|:---:|
| [glb_ip_address](outputs.tf#L17) | Load balancer IP address. | |

<!-- END TFDOC -->
20 changes: 10 additions & 10 deletions blueprints/networking/glb-hybrid-neg-internal/landing-hub.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down Expand Up @@ -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 = [
Expand All @@ -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

Expand All @@ -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}"
Expand All @@ -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
Expand Down Expand Up @@ -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}"
Expand All @@ -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}"
Expand All @@ -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 = {
Expand Down
5 changes: 5 additions & 0 deletions blueprints/networking/glb-hybrid-neg-internal/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
16 changes: 8 additions & 8 deletions blueprints/networking/glb-hybrid-neg-internal/spoke.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = [
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}"
Expand All @@ -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}"
Expand Down
30 changes: 21 additions & 9 deletions blueprints/networking/glb-hybrid-neg-internal/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/blueprints/networking/glb-hybrid-neg-internal/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Loading

0 comments on commit dd6edd8

Please sign in to comment.