diff --git a/modules/net-lb-ext/README.md b/modules/net-lb-ext/README.md
index f285d1229..c788023bc 100644
--- a/modules/net-lb-ext/README.md
+++ b/modules/net-lb-ext/README.md
@@ -197,23 +197,22 @@ module "nlb" {
## Deploying changes to load balancer configurations
For deploying changes to load balancer configuration please refer to [net-lb-app-ext README.md](../net-lb-app-ext/README.md#deploying-changes-to-load-balancer-configurations)
-
## Variables
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
-| [name](variables.tf#L198) | Name used for all resources. | string | ✓ | |
-| [project_id](variables.tf#L203) | Project id where resources will be created. | string | ✓ | |
-| [region](variables.tf#L208) | GCP region. | string | ✓ | |
-| [backend_service_config](variables.tf#L17) | Backend service level configuration. | object({…}) | | {} |
-| [backends](variables.tf#L66) | Load balancer backends. | list(object({…})) | | [] |
-| [description](variables.tf#L77) | Optional description used for resources. | string | | "Terraform managed." |
-| [forwarding_rules_config](variables.tf#L83) | The optional forwarding rules configuration. | map(object({…})) | | {…} |
-| [group_configs](variables.tf#L98) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | map(object({…})) | | {} |
-| [health_check](variables.tf#L109) | Name of existing health check to use, disables auto-created health check. | string | | null |
-| [health_check_config](variables.tf#L115) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | object({…}) | | {…} |
-| [labels](variables.tf#L192) | Labels set on resources. | map(string) | | {} |
+| [name](variables.tf#L201) | Name used for all resources. | string | ✓ | |
+| [project_id](variables.tf#L206) | Project id where resources will be created. | string | ✓ | |
+| [region](variables.tf#L211) | GCP region. | string | ✓ | |
+| [backend_service_config](variables.tf#L17) | Backend service level configuration. | object({…}) | | {} |
+| [backends](variables.tf#L67) | Load balancer backends. | list(object({…})) | | [] |
+| [description](variables.tf#L78) | Optional description used for resources. | string | | "Terraform managed." |
+| [forwarding_rules_config](variables.tf#L84) | The optional forwarding rules configuration. | map(object({…})) | | {…} |
+| [group_configs](variables.tf#L100) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | map(object({…})) | | {} |
+| [health_check](variables.tf#L111) | Name of existing health check to use, disables auto-created health check. | string | | null |
+| [health_check_config](variables.tf#L117) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | object({…}) | | {…} |
+| [labels](variables.tf#L195) | Labels set on resources. | map(string) | | {} |
## Outputs
diff --git a/modules/net-lb-ext/health-check.tf b/modules/net-lb-ext/health-check.tf
index d5208f08a..250058056 100644
--- a/modules/net-lb-ext/health-check.tf
+++ b/modules/net-lb-ext/health-check.tf
@@ -33,7 +33,7 @@ resource "google_compute_region_health_check" "default" {
count = local.hc != null ? 1 : 0
project = var.project_id
region = var.region
- name = var.name
+ name = local.hc.name != null ? local.hc.name : var.name
description = local.hc.description
check_interval_sec = local.hc.check_interval_sec
healthy_threshold = local.hc.healthy_threshold
diff --git a/modules/net-lb-ext/main.tf b/modules/net-lb-ext/main.tf
index 23bc7bdc3..852186852 100644
--- a/modules/net-lb-ext/main.tf
+++ b/modules/net-lb-ext/main.tf
@@ -30,13 +30,11 @@ moved {
}
resource "google_compute_forwarding_rule" "default" {
- for_each = var.forwarding_rules_config
- provider = google-beta
- project = var.project_id
- region = var.region
- name = (
- each.key == "" ? var.name : "${var.name}-${each.key}"
- )
+ for_each = var.forwarding_rules_config
+ provider = google-beta
+ project = var.project_id
+ region = var.region
+ name = coalesce(each.value.name, each.key == "" ? var.name : "${var.name}-${each.key}")
description = each.value.description
ip_address = each.value.address
ip_protocol = each.value.protocol
@@ -56,7 +54,7 @@ resource "google_compute_region_backend_service" "default" {
provider = google-beta
project = var.project_id
region = var.region
- name = var.name
+ name = coalesce(var.backend_service_config.name, var.name)
description = var.description
load_balancing_scheme = "EXTERNAL"
protocol = var.backend_service_config.protocol
diff --git a/modules/net-lb-ext/variables.tf b/modules/net-lb-ext/variables.tf
index f3bcd3ed8..7179309cf 100644
--- a/modules/net-lb-ext/variables.tf
+++ b/modules/net-lb-ext/variables.tf
@@ -30,6 +30,7 @@ variable "backend_service_config" {
}))
locality_lb_policy = optional(string)
log_sample_rate = optional(number)
+ name = optional(string)
port_name = optional(string)
protocol = optional(string, "UNSPECIFIED")
session_affinity = optional(string)
@@ -86,6 +87,7 @@ variable "forwarding_rules_config" {
address = optional(string)
description = optional(string)
ip_version = optional(string)
+ name = optional(string)
ports = optional(list(string), null)
protocol = optional(string, "TCP")
subnetwork = optional(string) # Required for IPv6
@@ -119,6 +121,7 @@ variable "health_check_config" {
description = optional(string, "Terraform managed.")
enable_logging = optional(bool, false)
healthy_threshold = optional(number)
+ name = optional(string)
timeout_sec = optional(number)
unhealthy_threshold = optional(number)
grpc = optional(object({
diff --git a/modules/net-lb-int/README.md b/modules/net-lb-int/README.md
index 48ecb3676..67065a3a2 100644
--- a/modules/net-lb-int/README.md
+++ b/modules/net-lb-int/README.md
@@ -364,20 +364,20 @@ One other issue is a `Provider produced inconsistent final plan` error which is
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
-| [name](variables.tf#L184) | Name used for all resources. | string | ✓ | |
-| [project_id](variables.tf#L189) | Project id where resources will be created. | string | ✓ | |
-| [region](variables.tf#L194) | GCP region. | string | ✓ | |
-| [vpc_config](variables.tf#L220) | VPC-level configuration. | object({…}) | ✓ | |
-| [backend_service_config](variables.tf#L17) | Backend service level configuration. | object({…}) | | {} |
-| [backends](variables.tf#L51) | Load balancer backends. | list(object({…})) | | [] |
-| [description](variables.tf#L62) | Optional description used for resources. | string | | "Terraform managed." |
-| [forwarding_rules_config](variables.tf#L68) | The optional forwarding rules configuration. | map(object({…})) | | {…} |
-| [group_configs](variables.tf#L83) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | map(object({…})) | | {} |
-| [health_check](variables.tf#L95) | Name of existing health check to use, disables auto-created health check. | string | | null |
-| [health_check_config](variables.tf#L101) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | object({…}) | | {…} |
-| [labels](variables.tf#L178) | Labels set on resources. | map(string) | | {} |
-| [service_attachments](variables.tf#L199) | PSC service attachments, keyed by forwarding rule. | map(object({…})) | | null |
-| [service_label](variables.tf#L214) | Optional prefix of the fully qualified forwarding rule name. | string | | null |
+| [name](variables.tf#L187) | Name used for all resources. | string | ✓ | |
+| [project_id](variables.tf#L192) | Project id where resources will be created. | string | ✓ | |
+| [region](variables.tf#L197) | GCP region. | string | ✓ | |
+| [vpc_config](variables.tf#L223) | VPC-level configuration. | object({…}) | ✓ | |
+| [backend_service_config](variables.tf#L17) | Backend service level configuration. | object({…}) | | {} |
+| [backends](variables.tf#L52) | Load balancer backends. | list(object({…})) | | [] |
+| [description](variables.tf#L63) | Optional description used for resources. | string | | "Terraform managed." |
+| [forwarding_rules_config](variables.tf#L69) | The optional forwarding rules configuration. | map(object({…})) | | {…} |
+| [group_configs](variables.tf#L85) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | map(object({…})) | | {} |
+| [health_check](variables.tf#L97) | Name of existing health check to use, disables auto-created health check. | string | | null |
+| [health_check_config](variables.tf#L103) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | object({…}) | | {…} |
+| [labels](variables.tf#L181) | Labels set on resources. | map(string) | | {} |
+| [service_attachments](variables.tf#L202) | PSC service attachments, keyed by forwarding rule. | map(object({…})) | | null |
+| [service_label](variables.tf#L217) | Optional prefix of the fully qualified forwarding rule name. | string | | null |
## Outputs
diff --git a/modules/net-lb-int/health-check.tf b/modules/net-lb-int/health-check.tf
index 4f5af03e7..1e0bd193b 100644
--- a/modules/net-lb-int/health-check.tf
+++ b/modules/net-lb-int/health-check.tf
@@ -32,7 +32,7 @@ resource "google_compute_health_check" "default" {
provider = google-beta
count = local.hc != null ? 1 : 0
project = var.project_id
- name = var.name
+ name = coalesce(local.hc.name, var.name)
description = local.hc.description
check_interval_sec = local.hc.check_interval_sec
healthy_threshold = local.hc.healthy_threshold
diff --git a/modules/net-lb-int/main.tf b/modules/net-lb-int/main.tf
index 9d993f5f5..895a82498 100644
--- a/modules/net-lb-int/main.tf
+++ b/modules/net-lb-int/main.tf
@@ -45,7 +45,7 @@ resource "google_compute_forwarding_rule" "default" {
for_each = var.forwarding_rules_config
provider = google-beta
project = var.project_id
- name = local.forwarding_rule_names[each.key]
+ name = coalesce(each.value.name, local.forwarding_rule_names[each.key])
region = var.region
description = each.value.description
ip_address = each.value.address
@@ -69,7 +69,7 @@ resource "google_compute_region_backend_service" "default" {
provider = google-beta
project = var.project_id
region = var.region
- name = var.name
+ name = coalesce(var.backend_service_config.name, var.name)
description = var.description
load_balancing_scheme = "INTERNAL"
protocol = var.backend_service_config.protocol
diff --git a/modules/net-lb-int/variables.tf b/modules/net-lb-int/variables.tf
index 8c001b673..5355f06cc 100644
--- a/modules/net-lb-int/variables.tf
+++ b/modules/net-lb-int/variables.tf
@@ -30,6 +30,7 @@ variable "backend_service_config" {
ratio = optional(number)
}))
log_sample_rate = optional(number)
+ name = optional(string)
protocol = optional(string, "UNSPECIFIED")
session_affinity = optional(string)
timeout_sec = optional(number)
@@ -72,6 +73,7 @@ variable "forwarding_rules_config" {
description = optional(string)
global_access = optional(bool, true)
ip_version = optional(string)
+ name = optional(string)
ports = optional(list(string), null)
protocol = optional(string, "TCP")
}))
@@ -105,6 +107,7 @@ variable "health_check_config" {
description = optional(string, "Terraform managed.")
enable_logging = optional(bool, false)
healthy_threshold = optional(number)
+ name = optional(string)
timeout_sec = optional(number)
unhealthy_threshold = optional(number)
grpc = optional(object({
diff --git a/modules/net-vpn-ha/README.md b/modules/net-vpn-ha/README.md
index aca124a15..3df0b9f66 100644
--- a/modules/net-vpn-ha/README.md
+++ b/modules/net-vpn-ha/README.md
@@ -209,13 +209,13 @@ module "vpn_ha" {
|---|---|:---:|:---:|:---:|
| [name](variables.tf#L17) | VPN Gateway name (if an existing VPN Gateway is not used), and prefix used for dependent resources. | string | ✓ | |
| [network](variables.tf#L22) | VPC used for the gateway and routes. | string | ✓ | |
-| [project_id](variables.tf#L47) | Project where resources will be created. | string | ✓ | |
-| [region](variables.tf#L52) | Region used for resources. | string | ✓ | |
-| [router_config](variables.tf#L57) | Cloud Router configuration for the VPN. If you want to reuse an existing router, set create to false and use name to specify the desired router. | object({…}) | ✓ | |
-| [peer_gateways](variables.tf#L27) | Configuration of the (external or GCP) peer gateway. | map(object({…})) | | {} |
-| [tunnels](variables.tf#L72) | VPN tunnel configurations. | map(object({…})) | | {} |
-| [vpn_gateway](variables.tf#L106) | HA VPN Gateway Self Link for using an existing HA VPN Gateway. Ignored if `vpn_gateway_create` is set to `true`. | string | | null |
-| [vpn_gateway_create](variables.tf#L112) | Create HA VPN Gateway. Set to null to avoid creation. | object({…}) | | {} |
+| [project_id](variables.tf#L48) | Project where resources will be created. | string | ✓ | |
+| [region](variables.tf#L53) | Region used for resources. | string | ✓ | |
+| [router_config](variables.tf#L58) | Cloud Router configuration for the VPN. If you want to reuse an existing router, set create to false and use name to specify the desired router. | object({…}) | ✓ | |
+| [peer_gateways](variables.tf#L27) | Configuration of the (external or GCP) peer gateway. | map(object({…})) | | {} |
+| [tunnels](variables.tf#L74) | VPN tunnel configurations. | map(object({…})) | | {} |
+| [vpn_gateway](variables.tf#L111) | HA VPN Gateway Self Link for using an existing HA VPN Gateway. Ignored if `vpn_gateway_create` is set to `true`. | string | | null |
+| [vpn_gateway_create](variables.tf#L117) | Create HA VPN Gateway. Set to null to avoid creation. | object({…}) | | {} |
## Outputs
diff --git a/modules/net-vpn-ha/main.tf b/modules/net-vpn-ha/main.tf
index a86491cd0..0162714f8 100644
--- a/modules/net-vpn-ha/main.tf
+++ b/modules/net-vpn-ha/main.tf
@@ -47,7 +47,7 @@ resource "google_compute_ha_vpn_gateway" "ha_gateway" {
resource "google_compute_external_vpn_gateway" "external_gateway" {
for_each = local.peer_gateways_external
- name = "${var.name}-${each.key}"
+ name = each.value.name != null ? each.value.name : "${var.name}-${each.key}"
project = var.project_id
redundancy_type = each.value.redundancy_type
description = each.value.description
@@ -94,7 +94,7 @@ resource "google_compute_router_peer" "bgp_peer" {
for_each = var.tunnels
region = var.region
project = var.project_id
- name = "${var.name}-${each.key}"
+ name = each.value.bgp_peer.name != null ? each.value.bgp_peer.name : "${var.name}-${each.key}"
router = coalesce(each.value.router, local.router)
peer_ip_address = each.value.bgp_peer.address
peer_asn = each.value.bgp_peer.asn
@@ -130,7 +130,7 @@ resource "google_compute_router_interface" "router_interface" {
for_each = var.tunnels
project = var.project_id
region = var.region
- name = "${var.name}-${each.key}"
+ name = each.value.peer_router_interface_name != null ? each.value.peer_router_interface_name : "${var.name}-${each.key}"
router = local.router
# FIXME: can bgp_session_range be null?
ip_range = each.value.bgp_session_range == "" ? null : each.value.bgp_session_range
@@ -141,7 +141,7 @@ resource "google_compute_vpn_tunnel" "tunnels" {
for_each = var.tunnels
project = var.project_id
region = var.region
- name = "${var.name}-${each.key}"
+ name = each.value.name != null ? each.value.name : "${var.name}-${each.key}"
router = local.router
peer_external_gateway = try(
google_compute_external_vpn_gateway.external_gateway[each.value.peer_gateway].id,
diff --git a/modules/net-vpn-ha/variables.tf b/modules/net-vpn-ha/variables.tf
index cae4c2536..d9b239261 100644
--- a/modules/net-vpn-ha/variables.tf
+++ b/modules/net-vpn-ha/variables.tf
@@ -1,5 +1,5 @@
/**
- * Copyright 2022 Google LLC
+ * 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.
@@ -31,6 +31,7 @@ variable "peer_gateways" {
redundancy_type = string
interfaces = list(string)
description = optional(string, "Terraform managed external VPN gateway")
+ name = optional(string)
}))
gcp = optional(string)
}))
@@ -63,8 +64,9 @@ variable "router_config" {
all_subnets = bool
ip_ranges = map(string)
}))
- keepalive = optional(number)
- name = optional(string)
+ keepalive = optional(number)
+ name = optional(string)
+ override_name = optional(string)
})
nullable = false
}
@@ -88,12 +90,15 @@ variable "tunnels" {
nexthop_address = optional(string)
peer_nexthop_address = optional(string)
}))
+ name = optional(string)
})
# each BGP session on the same Cloud Router must use a unique /30 CIDR
# from the 169.254.0.0/16 block.
bgp_session_range = string
ike_version = optional(number, 2)
+ name = optional(string)
peer_external_gateway_interface = optional(number)
+ peer_router_interface_name = optional(string)
peer_gateway = optional(string, "default")
router = optional(string)
shared_secret = optional(string)