From 649cab0020a149617691af66c3d130d83b332f2a Mon Sep 17 00:00:00 2001 From: David Liebert <58755731+LaoZhuBaba@users.noreply.github.com> Date: Wed, 14 Jan 2026 22:48:16 +1300 Subject: [PATCH] fixed bug where label field is ignored for policy based routes (#3648) * fixed bug where label field is ignored for policy based routes * Fix example and inventory * Add missing schema --------- Co-authored-by: Julio Castillo --- .../2-networking/schemas/vpc.schema.json | 53 ++++++++++++++++++- modules/net-vpc/README.md | 6 +++ modules/net-vpc/routes.tf | 1 + tests/modules/net_vpc/examples/pbr.yaml | 8 +-- 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/fast/stages/2-networking/schemas/vpc.schema.json b/fast/stages/2-networking/schemas/vpc.schema.json index f7a9462ac..bece09e25 100644 --- a/fast/stages/2-networking/schemas/vpc.schema.json +++ b/fast/stages/2-networking/schemas/vpc.schema.json @@ -247,7 +247,58 @@ "type": "object", "patternProperties": { "^[a-z0-9-]+$": { - "type": "object" + "type": "object", + "additionalProperties": false, + "properties": { + "description": { + "type": "string" + }, + "filter": { + "type": "object", + "additionalProperties": false, + "properties": { + "dest_range": { + "type": "string" + }, + "ip_protocol": { + "type": "string" + }, + "src_range": { + "type": "string" + } + } + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "next_hop_ilb_ip": { + "type": "string" + }, + "priority": { + "type": "number" + }, + "target": { + "type": "object", + "additionalProperties": false, + "properties": { + "interconnect_attachment": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "use_default_routing": { + "type": "boolean" + } + } } } }, diff --git a/modules/net-vpc/README.md b/modules/net-vpc/README.md index b4016f30e..9a15c01a2 100644 --- a/modules/net-vpc/README.md +++ b/modules/net-vpc/README.md @@ -640,6 +640,9 @@ module "vpc" { target = { tags = ["nva"] } + labels = { + environment = "prod" + } } send-all-to-nva = { next_hop_ilb_ip = "10.0.0.253" @@ -651,6 +654,9 @@ module "vpc" { target = { interconnect_attachment = "europe-west8" } + labels = { + environment = "prod" + } } } create_googleapis_routes = null diff --git a/modules/net-vpc/routes.tf b/modules/net-vpc/routes.tf index fff19bb36..b1bc6ca83 100644 --- a/modules/net-vpc/routes.tf +++ b/modules/net-vpc/routes.tf @@ -131,6 +131,7 @@ resource "google_network_connectivity_policy_based_route" "default" { network = local.network.id name = "${var.name}-${each.key}" description = each.value.description + labels = each.value.labels priority = each.value.priority next_hop_other_routes = each.value.use_default_routing ? "DEFAULT_ROUTING" : null next_hop_ilb_ip = each.value.use_default_routing ? null : each.value.next_hop_ilb_ip diff --git a/tests/modules/net_vpc/examples/pbr.yaml b/tests/modules/net_vpc/examples/pbr.yaml index 4255e4e66..f946187d8 100644 --- a/tests/modules/net_vpc/examples/pbr.yaml +++ b/tests/modules/net_vpc/examples/pbr.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,7 +32,8 @@ values: src_range: 10.0.0.0/8 interconnect_attachment: - region: europe-west8 - labels: null + labels: + environment: prod name: my-vpc-send-all-to-nva next_hop_ilb_ip: 10.0.0.253 next_hop_other_routes: null @@ -48,7 +49,8 @@ values: protocol_version: IPV4 src_range: 0.0.0.0/0 interconnect_attachment: [] - labels: null + labels: + environment: prod name: my-vpc-skip-pbr-for-nva next_hop_ilb_ip: null next_hop_other_routes: DEFAULT_ROUTING