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 <jccb@google.com>
This commit is contained in:
David Liebert
2026-01-14 22:48:16 +13:00
committed by GitHub
parent 032db2f902
commit 649cab0020
4 changed files with 64 additions and 4 deletions

View File

@@ -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"
}
}
}
}
},

View File

@@ -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

View File

@@ -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

View File

@@ -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