From b50e8a16dc416973659f7dcb2c0246703f34ab36 Mon Sep 17 00:00:00 2001 From: Samuele Perticarari Date: Sat, 15 Mar 2025 18:29:44 +0100 Subject: [PATCH] Fix subnet schema in net-vpc module & hybrid subnets example implementation (#2958) * Fixed subnet schema by adding "allow_subnet_cidr_routes_overlap" field * Implemented hybrid subnets code example and test code --- modules/net-vpc/README.md | 9 ++++++++- modules/net-vpc/schemas/subnet.schema.json | 3 +++ tests/modules/net_vpc/examples/subnet-options.yaml | 11 ++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/net-vpc/README.md b/modules/net-vpc/README.md index 003fcd2bd..e46b48fb8 100644 --- a/modules/net-vpc/README.md +++ b/modules/net-vpc/README.md @@ -95,10 +95,17 @@ module "vpc" { flow_sampling = 0.5 aggregation_interval = "INTERVAL_10_MIN" } + }, + # hybrid subnet + { + name = "hybrid" + region = "europe-west1" + ip_cidr_range = "10.0.4.0/24" + allow_subnet_cidr_routes_overlap = true } ] } -# tftest modules=1 resources=7 inventory=subnet-options.yaml e2e +# tftest modules=1 resources=8 inventory=subnet-options.yaml e2e ``` ### Subnet IAM diff --git a/modules/net-vpc/schemas/subnet.schema.json b/modules/net-vpc/schemas/subnet.schema.json index 9c2948abc..f8cb7d55d 100644 --- a/modules/net-vpc/schemas/subnet.schema.json +++ b/modules/net-vpc/schemas/subnet.schema.json @@ -17,6 +17,9 @@ "enable_private_access": { "type": "boolean" }, + "allow_subnet_cidr_routes_overlap": { + "type": "boolean" + }, "flow_logs_config": { "type": "object", "additionalProperties": false, diff --git a/tests/modules/net_vpc/examples/subnet-options.yaml b/tests/modules/net_vpc/examples/subnet-options.yaml index d500a9666..b9723f407 100644 --- a/tests/modules/net_vpc/examples/subnet-options.yaml +++ b/tests/modules/net_vpc/examples/subnet-options.yaml @@ -32,6 +32,15 @@ values: private_ip_google_access: true project: project-id region: europe-west1 + ? module.vpc.google_compute_subnetwork.subnetwork["europe-west1/hybrid"] + : description: Terraform-managed. + ip_cidr_range: 10.0.4.0/24 + log_config: [] + name: hybrid + private_ip_google_access: true + project: project-id + region: europe-west1 + allow_subnet_cidr_routes_overlap: true ? module.vpc.google_compute_subnetwork.subnetwork["europe-west1/with-flow-logs"] : description: Terraform-managed. ip_cidr_range: 10.0.3.0/24 @@ -64,4 +73,4 @@ values: counts: google_compute_network: 1 - google_compute_subnetwork: 4 + google_compute_subnetwork: 5