diff --git a/modules/net-address/README.md b/modules/net-address/README.md index eb07079db..87f543d6e 100644 --- a/modules/net-address/README.md +++ b/modules/net-address/README.md @@ -12,14 +12,17 @@ module "addresses" { project_id = var.project_id external_addresses = { one = { region = "europe-west1" } - two = { region = "europe-west2" } + two = { + region = "europe-west2" + tier = "STANDARD" + } } global_addresses = { app-1 = {} app-2 = {} } } -# tftest modules=1 resources=4 inventory=external.yaml +# tftest modules=1 resources=4 inventory=external.yaml e2e ``` ### Internal addresses @@ -35,13 +38,13 @@ module "addresses" { subnetwork = var.subnet.self_link } ilb-2 = { - address = "10.0.0.2" + address = "10.0.16.2" region = var.region subnetwork = var.subnet.self_link } } } -# tftest modules=1 resources=2 inventory=internal.yaml +# tftest modules=1 resources=2 inventory=internal.yaml e2e ``` ### IPv6 addresses @@ -55,7 +58,7 @@ module "addresses" { external_addresses = { nlb = { region = var.region - subnetwork = var.subnet.self_link + subnetwork = module.vpc.subnets["${var.region}/ipv6-external"].self_link ipv6 = { endpoint_type = "NETLB" } @@ -66,16 +69,16 @@ module "addresses" { ipv6 = {} purpose = "SHARED_LOADBALANCER_VIP" region = var.region - subnetwork = var.subnet.self_link + subnetwork = module.vpc.subnets["${var.region}/ipv6-internal"].self_link } vm = { ipv6 = {} region = var.region - subnetwork = var.subnet.self_link + subnetwork = module.vpc.subnets["${var.region}/ipv6-internal"].self_link } } } -# tftest modules=1 resources=3 inventory=ipv6.yaml +# tftest modules=2 resources=8 fixtures=fixtures/net-vpc-ipv6.tf inventory=ipv6.yaml e2e ``` ### PSA addresses @@ -92,7 +95,7 @@ module "addresses" { } } } -# tftest modules=1 resources=1 inventory=psa.yaml +# tftest modules=1 resources=1 inventory=psa.yaml e2e ``` ### PSC addresses @@ -112,7 +115,7 @@ module "addresses" { } } } -# tftest modules=1 resources=2 inventory=psc.yaml +# tftest modules=1 resources=2 inventory=psc.yaml e2e ``` # IPSec Interconnect addresses @@ -136,20 +139,20 @@ module "addresses" { } } } -# tftest modules=1 resources=2 inventory=ipsec-interconnect.yaml +# tftest modules=1 resources=2 inventory=ipsec-interconnect.yaml e2e ``` ## Variables | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [project_id](variables.tf#L84) | Project where the addresses will be created. | string | ✓ | | +| [project_id](variables.tf#L83) | Project where the addresses will be created. | string | ✓ | | | [external_addresses](variables.tf#L17) | Map of external addresses, keyed by name. | map(object({…})) | | {} | | [global_addresses](variables.tf#L39) | List of global addresses to create. | map(object({…})) | | {} | -| [internal_addresses](variables.tf#L49) | Map of internal addresses to create, keyed by name. | map(object({…})) | | {} | -| [ipsec_interconnect_addresses](variables.tf#L65) | Map of internal addresses used for HPA VPN over Cloud Interconnect. | map(object({…})) | | {} | -| [psa_addresses](variables.tf#L89) | Map of internal addresses used for Private Service Access. | map(object({…})) | | {} | -| [psc_addresses](variables.tf#L102) | Map of internal addresses used for Private Service Connect. | map(object({…})) | | {} | +| [internal_addresses](variables.tf#L49) | Map of internal addresses to create, keyed by name. | map(object({…})) | | {} | +| [ipsec_interconnect_addresses](variables.tf#L64) | Map of internal addresses used for HPA VPN over Cloud Interconnect. | map(object({…})) | | {} | +| [psa_addresses](variables.tf#L88) | Map of internal addresses used for Private Service Access. | map(object({…})) | | {} | +| [psc_addresses](variables.tf#L101) | Map of internal addresses used for Private Service Connect. | map(object({…})) | | {} | ## Outputs @@ -161,4 +164,8 @@ module "addresses" { | [ipsec_interconnect_addresses](outputs.tf#L41) | Allocated internal addresses for HA VPN over Cloud Interconnect. | | | [psa_addresses](outputs.tf#L49) | Allocated internal addresses for PSA endpoints. | | | [psc_addresses](outputs.tf#L57) | Allocated internal addresses for PSC endpoints. | | + +## Fixtures + +- [net-vpc-ipv6.tf](../../tests/fixtures/net-vpc-ipv6.tf) diff --git a/tests/fixtures/net-vpc-ipv6.tf b/tests/fixtures/net-vpc-ipv6.tf new file mode 100644 index 000000000..14d0dbbec --- /dev/null +++ b/tests/fixtures/net-vpc-ipv6.tf @@ -0,0 +1,40 @@ +# Copyright 2024 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. + +module "vpc" { + source = "./fabric/modules/net-vpc" + project_id = var.project_id + name = "fixture-net-vpc-external" + ipv6_config = { + enable_ula_internal = true + } + subnets = [ + { + ip_cidr_range = "192.168.0.0/24" + name = "ipv6-external" + region = var.region + ipv6 = { + access_type = "EXTERNAL" + } + }, + { + ip_cidr_range = "192.168.1.0/24" + name = "ipv6-internal" + region = var.region + ipv6 = { + access_type = "INTERNAL" + } + }, + ] +} \ No newline at end of file diff --git a/tests/modules/net_address/examples/internal.yaml b/tests/modules/net_address/examples/internal.yaml index 73d36a36d..435e63a5d 100644 --- a/tests/modules/net_address/examples/internal.yaml +++ b/tests/modules/net_address/examples/internal.yaml @@ -23,7 +23,7 @@ values: region: europe-west8 subnetwork: subnet_self_link module.addresses.google_compute_address.internal["ilb-2"]: - address: 10.0.0.2 + address: 10.0.16.2 address_type: INTERNAL labels: null name: ilb-2 diff --git a/tests/modules/net_address/examples/ipv6.yaml b/tests/modules/net_address/examples/ipv6.yaml index d075cc41f..509c47d5d 100644 --- a/tests/modules/net_address/examples/ipv6.yaml +++ b/tests/modules/net_address/examples/ipv6.yaml @@ -29,7 +29,6 @@ values: project: project-id purpose: SHARED_LOADBALANCER_VIP region: europe-west8 - subnetwork: subnet_self_link module.addresses.google_compute_address.internal["vm"]: address_type: INTERNAL ip_version: IPV6 @@ -38,7 +37,6 @@ values: network: null project: project-id region: europe-west8 - subnetwork: subnet_self_link counts: google_compute_address: 3