From 4035b35af3c6aed09e06cfce5861ebda82780dd5 Mon Sep 17 00:00:00 2001 From: Ayush Gupta Date: Fri, 18 Jul 2025 11:39:50 +0530 Subject: [PATCH 1/2] Allow custom names and descriptions for load balancer components (#3223) * feat: Changes for migrating resources to GLB module * Updated Readme * Added support for null description * Added support for empty string * Added default optional values * Changed Readme * Corrected description according to readme * Added name and description changes for net-lb-app-ext-regional * Added name and description changes for net-lb-app-int * Added name and description changes for net-lb-app-int-cross-region * Added name and description changes for net-lb-proxy-int * Added name and description changes for net-lb-ext * Added name and description changes for net-lb-int * Changed Readme docs --- modules/net-lb-app-ext-regional/README.md | 28 ++++++++-------- .../backend-service.tf | 4 +-- .../net-lb-app-ext-regional/health-check.tf | 2 +- modules/net-lb-app-ext-regional/main.tf | 6 ++-- modules/net-lb-app-ext-regional/urlmap.tf | 2 +- .../variables-backend-service.tf | 2 ++ .../variables-health-check.tf | 1 + .../variables-urlmap.tf | 1 + modules/net-lb-app-ext-regional/variables.tf | 3 ++ modules/net-lb-app-ext/README.md | 24 +++++++------- modules/net-lb-app-ext/backend-service.tf | 4 +-- modules/net-lb-app-ext/health-check.tf | 2 +- modules/net-lb-app-ext/main.tf | 8 ++--- modules/net-lb-app-ext/urlmap.tf | 2 +- .../variables-backend-service.tf | 2 ++ .../net-lb-app-ext/variables-health-check.tf | 1 + modules/net-lb-app-ext/variables-urlmap.tf | 1 + modules/net-lb-app-ext/variables.tf | 5 ++- modules/net-lb-app-int-cross-region/README.md | 24 +++++++------- .../backend-service.tf | 4 +-- .../health-check.tf | 2 +- modules/net-lb-app-int-cross-region/main.tf | 4 +-- modules/net-lb-app-int-cross-region/urlmap.tf | 2 +- .../variables-backend-service.tf | 2 ++ .../variables-health-check.tf | 1 + .../variables-urlmap.tf | 1 + .../net-lb-app-int-cross-region/variables.tf | 2 ++ modules/net-lb-app-int/README.md | 32 +++++++++---------- modules/net-lb-app-int/backend-service.tf | 4 +-- modules/net-lb-app-int/health-check.tf | 2 +- modules/net-lb-app-int/main.tf | 6 ++-- modules/net-lb-app-int/urlmap.tf | 2 +- .../variables-backend-service.tf | 2 ++ .../net-lb-app-int/variables-health-check.tf | 1 + modules/net-lb-app-int/variables-urlmap.tf | 1 + modules/net-lb-app-int/variables.tf | 3 ++ modules/net-lb-ext/README.md | 22 ++++++------- modules/net-lb-ext/main.tf | 2 +- modules/net-lb-ext/variables.tf | 1 + modules/net-lb-int/README.md | 28 ++++++++-------- modules/net-lb-int/main.tf | 2 +- modules/net-lb-int/variables.tf | 1 + modules/net-lb-proxy-int/README.md | 28 ++++++++-------- modules/net-lb-proxy-int/backend-service.tf | 4 +-- modules/net-lb-proxy-int/health-check.tf | 2 +- modules/net-lb-proxy-int/variables.tf | 3 ++ .../examples/http-https-redirect.yaml | 2 +- 47 files changed, 160 insertions(+), 128 deletions(-) diff --git a/modules/net-lb-app-ext-regional/README.md b/modules/net-lb-app-ext-regional/README.md index 44ae6c05c..91ef62951 100644 --- a/modules/net-lb-app-ext-regional/README.md +++ b/modules/net-lb-app-ext-regional/README.md @@ -798,23 +798,23 @@ For deploying changes to load balancer configuration please refer to [net-lb-app | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [name](variables.tf#L59) | Load balancer name. | string | ✓ | | -| [project_id](variables.tf#L184) | Project id. | string | ✓ | | -| [region](variables.tf#L202) | Region where the load balancer is created. | string | ✓ | | -| [vpc](variables.tf#L221) | VPC-level configuration. | string | ✓ | | +| [name](variables.tf#L61) | Load balancer name. | string | ✓ | | +| [project_id](variables.tf#L186) | Project id. | string | ✓ | | +| [region](variables.tf#L204) | Region where the load balancer is created. | string | ✓ | | +| [vpc](variables.tf#L224) | VPC-level configuration. | string | ✓ | | | [address](variables.tf#L17) | Optional IP address used for the forwarding rule. | string | | null | -| [backend_service_configs](variables-backend-service.tf#L19) | Backend service level configuration. | map(object({…})) | | {} | +| [backend_service_configs](variables-backend-service.tf#L19) | Backend service level configuration. | map(object({…})) | | {} | | [description](variables.tf#L23) | Optional description used for resources. | string | | "Terraform managed." | | [group_configs](variables.tf#L29) | Optional unmanaged groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | map(object({…})) | | {…} | -| [https_proxy_config](variables.tf#L41) | HTTPS proxy connfiguration. | object({…}) | | {} | -| [labels](variables.tf#L53) | Labels set on resources. | map(string) | | {} | -| [neg_configs](variables.tf#L64) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [network_tier_standard](variables.tf#L167) | Use standard network tier. | bool | | true | -| [ports](variables.tf#L174) | Optional ports for HTTP load balancer. | list(string) | | null | -| [protocol](variables.tf#L189) | Protocol supported by this load balancer. | string | | "HTTP" | -| [ssl_certificates](variables.tf#L207) | SSL target proxy certificates (only if protocol is HTTPS) for existing, custom, and managed certificates. | object({…}) | | {} | -| [urlmap_config](variables-urlmap.tf#L19) | The URL map configuration. | object({…}) | | {…} | +| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | map(object({…})) | | {…} | +| [https_proxy_config](variables.tf#L41) | HTTPS proxy connfiguration. | object({…}) | | {} | +| [labels](variables.tf#L55) | Labels set on resources. | map(string) | | {} | +| [neg_configs](variables.tf#L66) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | +| [network_tier_standard](variables.tf#L169) | Use standard network tier. | bool | | true | +| [ports](variables.tf#L176) | Optional ports for HTTP load balancer. | list(string) | | null | +| [protocol](variables.tf#L191) | Protocol supported by this load balancer. | string | | "HTTP" | +| [ssl_certificates](variables.tf#L209) | SSL target proxy certificates (only if protocol is HTTPS) for existing, custom, and managed certificates. | object({…}) | | {} | +| [urlmap_config](variables-urlmap.tf#L19) | The URL map configuration. | object({…}) | | {…} | ## Outputs diff --git a/modules/net-lb-app-ext-regional/backend-service.tf b/modules/net-lb-app-ext-regional/backend-service.tf index 75dc946f6..b40258bdf 100644 --- a/modules/net-lb-app-ext-regional/backend-service.tf +++ b/modules/net-lb-app-ext-regional/backend-service.tf @@ -47,9 +47,9 @@ resource "google_compute_region_backend_service" "default" { ? var.project_id : each.value.project_id ) - name = "${var.name}-${each.key}" + name = coalesce(each.value.name, "${var.name}-${each.key}") region = var.region - description = var.description + description = each.value.description affinity_cookie_ttl_sec = each.value.affinity_cookie_ttl_sec connection_draining_timeout_sec = each.value.connection_draining_timeout_sec enable_cdn = each.value.enable_cdn diff --git a/modules/net-lb-app-ext-regional/health-check.tf b/modules/net-lb-app-ext-regional/health-check.tf index f7dc9c178..22dc878b8 100644 --- a/modules/net-lb-app-ext-regional/health-check.tf +++ b/modules/net-lb-app-ext-regional/health-check.tf @@ -24,7 +24,7 @@ resource "google_compute_region_health_check" "default" { ? var.project_id : each.value.project_id ) - name = "${var.name}-${each.key}" + name = coalesce(each.value.name, "${var.name}-${each.key}") region = var.region description = each.value.description check_interval_sec = each.value.check_interval_sec diff --git a/modules/net-lb-app-ext-regional/main.tf b/modules/net-lb-app-ext-regional/main.tf index c009c4c2c..74b77eec5 100644 --- a/modules/net-lb-app-ext-regional/main.tf +++ b/modules/net-lb-app-ext-regional/main.tf @@ -48,7 +48,7 @@ resource "google_compute_forwarding_rule" "default" { resource "google_compute_region_ssl_certificate" "default" { for_each = var.ssl_certificates.create_configs project = var.project_id - name = "${var.name}-${each.key}" + name = coalesce(each.value.name, "${var.name}-${each.key}") region = var.region certificate = trimspace(each.value.certificate) private_key = trimspace(each.value.private_key) @@ -69,9 +69,9 @@ resource "google_compute_region_target_http_proxy" "default" { resource "google_compute_region_target_https_proxy" "default" { count = var.protocol == "HTTPS" ? 1 : 0 project = var.project_id - name = var.name + name = coalesce(var.https_proxy_config.name, var.name) region = var.region - description = var.description + description = var.https_proxy_config.description certificate_manager_certificates = var.https_proxy_config.certificate_manager_certificates ssl_certificates = length(local.proxy_ssl_certificates) == 0 ? null : local.proxy_ssl_certificates ssl_policy = var.https_proxy_config.ssl_policy diff --git a/modules/net-lb-app-ext-regional/urlmap.tf b/modules/net-lb-app-ext-regional/urlmap.tf index f88cc0a38..ee19d6d51 100644 --- a/modules/net-lb-app-ext-regional/urlmap.tf +++ b/modules/net-lb-app-ext-regional/urlmap.tf @@ -27,7 +27,7 @@ resource "google_compute_region_url_map" "default" { project = var.project_id name = var.name region = var.region - description = var.description + description = var.urlmap_config.description default_service = ( var.urlmap_config.default_service == null ? null : lookup( local.backend_ids, diff --git a/modules/net-lb-app-ext-regional/variables-backend-service.tf b/modules/net-lb-app-ext-regional/variables-backend-service.tf index 78146d431..810513ffc 100644 --- a/modules/net-lb-app-ext-regional/variables-backend-service.tf +++ b/modules/net-lb-app-ext-regional/variables-backend-service.tf @@ -19,6 +19,8 @@ variable "backend_service_configs" { description = "Backend service level configuration." type = map(object({ + name = optional(string) + description = optional(string, "Terraform managed.") affinity_cookie_ttl_sec = optional(number) connection_draining_timeout_sec = optional(number) enable_cdn = optional(bool) diff --git a/modules/net-lb-app-ext-regional/variables-health-check.tf b/modules/net-lb-app-ext-regional/variables-health-check.tf index be34d779d..98a4ff0b9 100644 --- a/modules/net-lb-app-ext-regional/variables-health-check.tf +++ b/modules/net-lb-app-ext-regional/variables-health-check.tf @@ -19,6 +19,7 @@ variable "health_check_configs" { description = "Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage." type = map(object({ + name = optional(string) check_interval_sec = optional(number) description = optional(string, "Terraform managed.") enable_logging = optional(bool, false) diff --git a/modules/net-lb-app-ext-regional/variables-urlmap.tf b/modules/net-lb-app-ext-regional/variables-urlmap.tf index 385cf687e..71318734e 100644 --- a/modules/net-lb-app-ext-regional/variables-urlmap.tf +++ b/modules/net-lb-app-ext-regional/variables-urlmap.tf @@ -19,6 +19,7 @@ variable "urlmap_config" { description = "The URL map configuration." type = object({ + description = optional(string, "Terraform managed.") default_route_action = optional(object({ request_mirror_backend = optional(string) cors_policy = optional(object({ diff --git a/modules/net-lb-app-ext-regional/variables.tf b/modules/net-lb-app-ext-regional/variables.tf index 65e793d7d..e9575effe 100644 --- a/modules/net-lb-app-ext-regional/variables.tf +++ b/modules/net-lb-app-ext-regional/variables.tf @@ -41,6 +41,8 @@ variable "group_configs" { variable "https_proxy_config" { description = "HTTPS proxy connfiguration." type = object({ + name = optional(string) + description = optional(string, "Terraform managed.") certificate_manager_certificates = optional(list(string)) certificate_map = optional(string) quic_override = optional(string) @@ -209,6 +211,7 @@ variable "ssl_certificates" { type = object({ certificate_ids = optional(list(string), []) create_configs = optional(map(object({ + name = optional(string) certificate = string private_key = string })), {}) diff --git a/modules/net-lb-app-ext/README.md b/modules/net-lb-app-ext/README.md index f63c5a20b..0de289679 100644 --- a/modules/net-lb-app-ext/README.md +++ b/modules/net-lb-app-ext/README.md @@ -1062,21 +1062,21 @@ After provisioning this change, and verifying that the new certificate is provis | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [name](variables.tf#L108) | Load balancer name. | string | ✓ | | -| [project_id](variables.tf#L204) | Project id. | string | ✓ | | +| [name](variables.tf#L110) | Load balancer name. | string | ✓ | | +| [project_id](variables.tf#L206) | Project id. | string | ✓ | | | [backend_buckets_config](variables.tf#L17) | Backend buckets configuration. | map(object({…})) | | {} | -| [backend_service_configs](variables-backend-service.tf#L19) | Backend service level configuration. | map(object({…})) })) | | {} | +| [backend_service_configs](variables-backend-service.tf#L19) | Backend service level configuration. | map(object({…})) })) | | {} | | [description](variables.tf#L50) | Optional description used for resources. | string | | "Terraform managed." | -| [forwarding_rules_config](variables.tf#L56) | The optional forwarding rules configuration. | map(object({…})) | | {…} | +| [forwarding_rules_config](variables.tf#L56) | The optional forwarding rules configuration. | map(object({…})) | | {…} | | [group_configs](variables.tf#L77) | Optional unmanaged groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | map(object({…})) | | {…} | -| [https_proxy_config](variables.tf#L89) | HTTPS proxy connfiguration. | object({…}) | | {} | -| [labels](variables.tf#L102) | Labels set on resources. | map(string) | | {} | -| [neg_configs](variables.tf#L113) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [protocol](variables.tf#L209) | Protocol supported by this load balancer. | string | | "HTTP" | -| [ssl_certificates](variables.tf#L222) | SSL target proxy certificates (only if protocol is HTTPS) for existing, custom, and managed certificates. | object({…}) | | {} | -| [urlmap_config](variables-urlmap.tf#L19) | The URL map configuration. | object({…}) | | {…} | -| [use_classic_version](variables.tf#L239) | Use classic Global Load Balancer. | bool | | true | +| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | map(object({…})) | | {…} | +| [https_proxy_config](variables.tf#L89) | HTTPS proxy connfiguration. | object({…}) | | {} | +| [labels](variables.tf#L104) | Labels set on resources. | map(string) | | {} | +| [neg_configs](variables.tf#L115) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | +| [protocol](variables.tf#L211) | Protocol supported by this load balancer. | string | | "HTTP" | +| [ssl_certificates](variables.tf#L224) | SSL target proxy certificates (only if protocol is HTTPS) for existing, custom, and managed certificates. | object({…}) | | {} | +| [urlmap_config](variables-urlmap.tf#L19) | The URL map configuration. | object({…}) | | {…} | +| [use_classic_version](variables.tf#L242) | Use classic Global Load Balancer. | bool | | true | ## Outputs diff --git a/modules/net-lb-app-ext/backend-service.tf b/modules/net-lb-app-ext/backend-service.tf index cc35606e4..9854e4925 100644 --- a/modules/net-lb-app-ext/backend-service.tf +++ b/modules/net-lb-app-ext/backend-service.tf @@ -49,8 +49,8 @@ resource "google_compute_backend_service" "default" { ? var.project_id : each.value.project_id ) - name = "${var.name}-${each.key}" - description = var.description + name = coalesce(each.value.name, "${var.name}-${each.key}") + description = each.value.description affinity_cookie_ttl_sec = each.value.affinity_cookie_ttl_sec compression_mode = each.value.compression_mode connection_draining_timeout_sec = each.value.connection_draining_timeout_sec diff --git a/modules/net-lb-app-ext/health-check.tf b/modules/net-lb-app-ext/health-check.tf index 66ba58c56..4cfefd01a 100644 --- a/modules/net-lb-app-ext/health-check.tf +++ b/modules/net-lb-app-ext/health-check.tf @@ -24,7 +24,7 @@ resource "google_compute_health_check" "default" { ? var.project_id : each.value.project_id ) - name = "${var.name}-${each.key}" + name = coalesce(each.value.name, "${var.name}-${each.key}") description = each.value.description check_interval_sec = each.value.check_interval_sec healthy_threshold = each.value.healthy_threshold diff --git a/modules/net-lb-app-ext/main.tf b/modules/net-lb-app-ext/main.tf index e8273263f..621d40f4f 100644 --- a/modules/net-lb-app-ext/main.tf +++ b/modules/net-lb-app-ext/main.tf @@ -46,7 +46,7 @@ resource "google_compute_global_forwarding_rule" "default" { for_each = var.forwarding_rules_config project = var.project_id name = coalesce(each.value.name, local.fwd_rule_names[each.key]) - description = coalesce(each.value.description, var.description) + description = each.value.description ip_address = each.value.address ip_protocol = "TCP" ip_version = each.value.address != null ? null : each.value.ipv6 == true ? "IPV6" : "IPV4" # do not set if address is provided @@ -73,7 +73,7 @@ resource "google_compute_ssl_certificate" "default" { resource "google_compute_managed_ssl_certificate" "default" { for_each = var.ssl_certificates.managed_configs project = var.project_id - name = "${var.name}-${each.key}" + name = coalesce(each.value.name, "${var.name}-${each.key}") description = each.value.description managed { domains = each.value.domains @@ -93,8 +93,8 @@ resource "google_compute_target_http_proxy" "default" { resource "google_compute_target_https_proxy" "default" { count = var.protocol == "HTTPS" ? 1 : 0 project = var.project_id - name = var.name - description = var.description + name = coalesce(var.https_proxy_config.name, var.name) + description = var.https_proxy_config.description certificate_map = var.https_proxy_config.certificate_map certificate_manager_certificates = var.https_proxy_config.certificate_manager_certificates quic_override = var.https_proxy_config.quic_override diff --git a/modules/net-lb-app-ext/urlmap.tf b/modules/net-lb-app-ext/urlmap.tf index 3a6e8888b..6017c2f9c 100644 --- a/modules/net-lb-app-ext/urlmap.tf +++ b/modules/net-lb-app-ext/urlmap.tf @@ -27,7 +27,7 @@ resource "google_compute_url_map" "default" { provider = google-beta project = var.project_id name = var.name - description = var.description + description = var.urlmap_config.description default_service = ( var.urlmap_config.default_service == null ? null : lookup( local.backend_ids, diff --git a/modules/net-lb-app-ext/variables-backend-service.tf b/modules/net-lb-app-ext/variables-backend-service.tf index 19e88cb49..48b85ca5d 100644 --- a/modules/net-lb-app-ext/variables-backend-service.tf +++ b/modules/net-lb-app-ext/variables-backend-service.tf @@ -19,6 +19,8 @@ variable "backend_service_configs" { description = "Backend service level configuration." type = map(object({ + name = optional(string) + description = optional(string, "Terraform managed.") affinity_cookie_ttl_sec = optional(number) compression_mode = optional(string) connection_draining_timeout_sec = optional(number) diff --git a/modules/net-lb-app-ext/variables-health-check.tf b/modules/net-lb-app-ext/variables-health-check.tf index be34d779d..98a4ff0b9 100644 --- a/modules/net-lb-app-ext/variables-health-check.tf +++ b/modules/net-lb-app-ext/variables-health-check.tf @@ -19,6 +19,7 @@ variable "health_check_configs" { description = "Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage." type = map(object({ + name = optional(string) check_interval_sec = optional(number) description = optional(string, "Terraform managed.") enable_logging = optional(bool, false) diff --git a/modules/net-lb-app-ext/variables-urlmap.tf b/modules/net-lb-app-ext/variables-urlmap.tf index e6ffe5551..85d4fe718 100644 --- a/modules/net-lb-app-ext/variables-urlmap.tf +++ b/modules/net-lb-app-ext/variables-urlmap.tf @@ -19,6 +19,7 @@ variable "urlmap_config" { description = "The URL map configuration." type = object({ + description = optional(string, "Terraform managed.") default_custom_error_response_policy = optional(object({ error_service = optional(string) error_response_rules = optional(list(object({ diff --git a/modules/net-lb-app-ext/variables.tf b/modules/net-lb-app-ext/variables.tf index 14facb2c9..55723d80b 100644 --- a/modules/net-lb-app-ext/variables.tf +++ b/modules/net-lb-app-ext/variables.tf @@ -57,7 +57,7 @@ variable "forwarding_rules_config" { description = "The optional forwarding rules configuration." type = map(object({ address = optional(string) - description = optional(string) + description = optional(string, "Terraform managed.") ipv6 = optional(bool, false) name = optional(string) ports = optional(list(number), null) @@ -89,6 +89,8 @@ variable "group_configs" { variable "https_proxy_config" { description = "HTTPS proxy connfiguration." type = object({ + name = optional(string) + description = optional(string, "Terraform managed.") certificate_manager_certificates = optional(list(string)) certificate_map = optional(string) quic_override = optional(string) @@ -228,6 +230,7 @@ variable "ssl_certificates" { private_key = string })), {}) managed_configs = optional(map(object({ + name = optional(string) domains = list(string) description = optional(string) })), {}) diff --git a/modules/net-lb-app-int-cross-region/README.md b/modules/net-lb-app-int-cross-region/README.md index 0a368396c..415efebca 100644 --- a/modules/net-lb-app-int-cross-region/README.md +++ b/modules/net-lb-app-int-cross-region/README.md @@ -751,21 +751,21 @@ When deploying changes to load balancer configuration please refer to [net-lb-ap | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [name](variables.tf#L58) | Load balancer name. | string | ✓ | | -| [project_id](variables.tf#L139) | Project id. | string | ✓ | | -| [vpc_config](variables.tf#L166) | VPC-level configuration. | object({…}) | ✓ | | +| [name](variables.tf#L60) | Load balancer name. | string | ✓ | | +| [project_id](variables.tf#L141) | Project id. | string | ✓ | | +| [vpc_config](variables.tf#L168) | VPC-level configuration. | object({…}) | ✓ | | | [addresses](variables.tf#L17) | Optional IP address used for the forwarding rule. | map(string) | | null | -| [backend_service_configs](variables-backend-service.tf#L19) | Backend service level configuration. | map(object({…})) | | {} | +| [backend_service_configs](variables-backend-service.tf#L19) | Backend service level configuration. | map(object({…})) | | {} | | [description](variables.tf#L23) | Optional description used for resources. | string | | "Terraform managed." | | [group_configs](variables.tf#L29) | Optional unmanaged groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | map(object({…})) | | {…} | -| [https_proxy_config](variables.tf#L41) | HTTPS proxy configuration. | object({…}) | | {} | -| [labels](variables.tf#L52) | Labels set on resources. | map(string) | | {} | -| [neg_configs](variables.tf#L63) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [ports](variables.tf#L129) | Optional ports for HTTP load balancer. | list(string) | | null | -| [protocol](variables.tf#L144) | Protocol supported by this load balancer. | string | | "HTTP" | -| [service_directory_registration](variables.tf#L157) | Service directory namespace and service used to register this load balancer. | object({…}) | | null | -| [urlmap_config](variables-urlmap.tf#L19) | The URL map configuration. | object({…}) | | {…} | +| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | map(object({…})) | | {…} | +| [https_proxy_config](variables.tf#L41) | HTTPS proxy configuration. | object({…}) | | {} | +| [labels](variables.tf#L54) | Labels set on resources. | map(string) | | {} | +| [neg_configs](variables.tf#L65) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | +| [ports](variables.tf#L131) | Optional ports for HTTP load balancer. | list(string) | | null | +| [protocol](variables.tf#L146) | Protocol supported by this load balancer. | string | | "HTTP" | +| [service_directory_registration](variables.tf#L159) | Service directory namespace and service used to register this load balancer. | object({…}) | | null | +| [urlmap_config](variables-urlmap.tf#L19) | The URL map configuration. | object({…}) | | {…} | ## Outputs diff --git a/modules/net-lb-app-int-cross-region/backend-service.tf b/modules/net-lb-app-int-cross-region/backend-service.tf index 7b62f0a48..f72fb3918 100644 --- a/modules/net-lb-app-int-cross-region/backend-service.tf +++ b/modules/net-lb-app-int-cross-region/backend-service.tf @@ -44,8 +44,8 @@ resource "google_compute_backend_service" "default" { ? var.project_id : each.value.project_id ) - name = "${var.name}-${each.key}" - description = var.description + name = coalesce(each.value.name, "${var.name}-${each.key}") + description = each.value.description affinity_cookie_ttl_sec = each.value.affinity_cookie_ttl_sec connection_draining_timeout_sec = each.value.connection_draining_timeout_sec health_checks = length(each.value.health_checks) == 0 ? null : [ diff --git a/modules/net-lb-app-int-cross-region/health-check.tf b/modules/net-lb-app-int-cross-region/health-check.tf index 66ba58c56..4cfefd01a 100644 --- a/modules/net-lb-app-int-cross-region/health-check.tf +++ b/modules/net-lb-app-int-cross-region/health-check.tf @@ -24,7 +24,7 @@ resource "google_compute_health_check" "default" { ? var.project_id : each.value.project_id ) - name = "${var.name}-${each.key}" + name = coalesce(each.value.name, "${var.name}-${each.key}") description = each.value.description check_interval_sec = each.value.check_interval_sec healthy_threshold = each.value.healthy_threshold diff --git a/modules/net-lb-app-int-cross-region/main.tf b/modules/net-lb-app-int-cross-region/main.tf index a46e01829..c43f190b2 100644 --- a/modules/net-lb-app-int-cross-region/main.tf +++ b/modules/net-lb-app-int-cross-region/main.tf @@ -90,8 +90,8 @@ resource "google_compute_target_http_proxy" "default" { resource "google_compute_target_https_proxy" "default" { count = var.protocol == "HTTPS" ? 1 : 0 project = var.project_id - name = var.name - description = var.description + name = coalesce(var.https_proxy_config.name, var.name) + description = var.https_proxy_config.description certificate_manager_certificates = var.https_proxy_config.certificate_manager_certificates quic_override = var.https_proxy_config.quic_override ssl_policy = var.https_proxy_config.ssl_policy diff --git a/modules/net-lb-app-int-cross-region/urlmap.tf b/modules/net-lb-app-int-cross-region/urlmap.tf index 62ccd9a92..739318795 100644 --- a/modules/net-lb-app-int-cross-region/urlmap.tf +++ b/modules/net-lb-app-int-cross-region/urlmap.tf @@ -26,7 +26,7 @@ resource "google_compute_url_map" "default" { provider = google-beta project = var.project_id name = var.name - description = var.description + description = var.urlmap_config.description default_service = ( var.urlmap_config.default_service == null ? null : lookup( local.backend_ids, diff --git a/modules/net-lb-app-int-cross-region/variables-backend-service.tf b/modules/net-lb-app-int-cross-region/variables-backend-service.tf index 7a7bfd8f2..223c7983b 100644 --- a/modules/net-lb-app-int-cross-region/variables-backend-service.tf +++ b/modules/net-lb-app-int-cross-region/variables-backend-service.tf @@ -19,6 +19,8 @@ variable "backend_service_configs" { description = "Backend service level configuration." type = map(object({ + name = optional(string) + description = optional(string, "Terraform managed.") affinity_cookie_ttl_sec = optional(number) connection_draining_timeout_sec = optional(number) health_checks = optional(list(string), ["default"]) diff --git a/modules/net-lb-app-int-cross-region/variables-health-check.tf b/modules/net-lb-app-int-cross-region/variables-health-check.tf index a51994ecf..a20d0e085 100644 --- a/modules/net-lb-app-int-cross-region/variables-health-check.tf +++ b/modules/net-lb-app-int-cross-region/variables-health-check.tf @@ -19,6 +19,7 @@ variable "health_check_configs" { description = "Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage." type = map(object({ + name = optional(string) check_interval_sec = optional(number) description = optional(string, "Terraform managed.") enable_logging = optional(bool, false) diff --git a/modules/net-lb-app-int-cross-region/variables-urlmap.tf b/modules/net-lb-app-int-cross-region/variables-urlmap.tf index ee48b7df0..bb7174662 100644 --- a/modules/net-lb-app-int-cross-region/variables-urlmap.tf +++ b/modules/net-lb-app-int-cross-region/variables-urlmap.tf @@ -19,6 +19,7 @@ variable "urlmap_config" { description = "The URL map configuration." type = object({ + description = optional(string, "Terraform managed.") default_service = optional(string) default_url_redirect = optional(object({ host = optional(string) diff --git a/modules/net-lb-app-int-cross-region/variables.tf b/modules/net-lb-app-int-cross-region/variables.tf index b1030e4ea..74398f316 100644 --- a/modules/net-lb-app-int-cross-region/variables.tf +++ b/modules/net-lb-app-int-cross-region/variables.tf @@ -41,6 +41,8 @@ variable "group_configs" { variable "https_proxy_config" { description = "HTTPS proxy configuration." type = object({ + name = optional(string) + description = optional(string, "Terraform managed.") certificate_manager_certificates = optional(list(string), []) quic_override = optional(string) ssl_policy = optional(string) diff --git a/modules/net-lb-app-int/README.md b/modules/net-lb-app-int/README.md index 2b7cf650c..b002cf6f0 100644 --- a/modules/net-lb-app-int/README.md +++ b/modules/net-lb-app-int/README.md @@ -781,26 +781,26 @@ For deploying changes to load balancer configuration please refer to [net-lb-app | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [name](variables.tf#L64) | Load balancer name. | string | ✓ | | -| [project_id](variables.tf#L164) | Project id. | string | ✓ | | -| [region](variables.tf#L182) | The region where to allocate the ILB resources. | string | ✓ | | -| [vpc_config](variables.tf#L224) | VPC-level configuration. | object({…}) | ✓ | | +| [name](variables.tf#L66) | Load balancer name. | string | ✓ | | +| [project_id](variables.tf#L166) | Project id. | string | ✓ | | +| [region](variables.tf#L184) | The region where to allocate the ILB resources. | string | ✓ | | +| [vpc_config](variables.tf#L227) | VPC-level configuration. | object({…}) | ✓ | | | [address](variables.tf#L17) | Optional IP address used for the forwarding rule. | string | | null | -| [backend_service_configs](variables-backend-service.tf#L19) | Backend service level configuration. | map(object({…})) | | {} | +| [backend_service_configs](variables-backend-service.tf#L19) | Backend service level configuration. | map(object({…})) | | {} | | [description](variables.tf#L23) | Optional description used for resources. | string | | "Terraform managed." | | [global_access](variables.tf#L30) | Allow client access from all regions. | bool | | null | | [group_configs](variables.tf#L36) | Optional unmanaged groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | map(object({…})) | | {…} | -| [https_proxy_config](variables.tf#L48) | HTTPS proxy configuration. | object({…}) | | {} | -| [labels](variables.tf#L58) | Labels set on resources. | map(string) | | {} | -| [neg_configs](variables.tf#L69) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [network_tier_premium](variables.tf#L147) | Use premium network tier. Defaults to true. | bool | | true | -| [ports](variables.tf#L154) | Optional ports for HTTP load balancer. | list(string) | | null | -| [protocol](variables.tf#L169) | Protocol supported by this load balancer. | string | | "HTTP" | -| [service_attachment](variables.tf#L187) | PSC service attachment. | object({…}) | | null | -| [service_directory_registration](variables.tf#L202) | Service directory namespace and service used to register this load balancer. | object({…}) | | null | -| [ssl_certificates](variables.tf#L211) | SSL target proxy certificates (only if protocol is HTTPS). | object({…}) | | {} | -| [urlmap_config](variables-urlmap.tf#L19) | The URL map configuration. | object({…}) | | {…} | +| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | map(object({…})) | | {…} | +| [https_proxy_config](variables.tf#L48) | HTTPS proxy configuration. | object({…}) | | {} | +| [labels](variables.tf#L60) | Labels set on resources. | map(string) | | {} | +| [neg_configs](variables.tf#L71) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | +| [network_tier_premium](variables.tf#L149) | Use premium network tier. Defaults to true. | bool | | true | +| [ports](variables.tf#L156) | Optional ports for HTTP load balancer. | list(string) | | null | +| [protocol](variables.tf#L171) | Protocol supported by this load balancer. | string | | "HTTP" | +| [service_attachment](variables.tf#L189) | PSC service attachment. | object({…}) | | null | +| [service_directory_registration](variables.tf#L204) | Service directory namespace and service used to register this load balancer. | object({…}) | | null | +| [ssl_certificates](variables.tf#L213) | SSL target proxy certificates (only if protocol is HTTPS). | object({…}) | | {} | +| [urlmap_config](variables-urlmap.tf#L19) | The URL map configuration. | object({…}) | | {…} | ## Outputs diff --git a/modules/net-lb-app-int/backend-service.tf b/modules/net-lb-app-int/backend-service.tf index d4f5a8dee..95072ba33 100644 --- a/modules/net-lb-app-int/backend-service.tf +++ b/modules/net-lb-app-int/backend-service.tf @@ -51,8 +51,8 @@ resource "google_compute_region_backend_service" "default" { : each.value.project_id ) region = var.region - name = "${var.name}-${each.key}" - description = var.description + name = coalesce(each.value.name, "${var.name}-${each.key}") + description = each.value.description affinity_cookie_ttl_sec = each.value.affinity_cookie_ttl_sec connection_draining_timeout_sec = each.value.connection_draining_timeout_sec health_checks = length(each.value.health_checks) == 0 ? null : [ diff --git a/modules/net-lb-app-int/health-check.tf b/modules/net-lb-app-int/health-check.tf index 66ba58c56..4cfefd01a 100644 --- a/modules/net-lb-app-int/health-check.tf +++ b/modules/net-lb-app-int/health-check.tf @@ -24,7 +24,7 @@ resource "google_compute_health_check" "default" { ? var.project_id : each.value.project_id ) - name = "${var.name}-${each.key}" + name = coalesce(each.value.name, "${var.name}-${each.key}") description = each.value.description check_interval_sec = each.value.check_interval_sec healthy_threshold = each.value.healthy_threshold diff --git a/modules/net-lb-app-int/main.tf b/modules/net-lb-app-int/main.tf index 841181f59..da2163dd8 100644 --- a/modules/net-lb-app-int/main.tf +++ b/modules/net-lb-app-int/main.tf @@ -89,7 +89,7 @@ resource "google_compute_region_ssl_certificate" "default" { for_each = var.ssl_certificates.create_configs project = var.project_id region = var.region - name = "${var.name}-${each.key}" + name = coalesce(each.value.name, "${var.name}-${each.key}") certificate = each.value.certificate private_key = each.value.private_key @@ -111,8 +111,8 @@ resource "google_compute_region_target_https_proxy" "default" { count = var.protocol == "HTTPS" ? 1 : 0 project = var.project_id region = var.region - name = var.name - description = var.description + name = coalesce(var.https_proxy_config.name, var.name) + description = var.https_proxy_config.description ssl_certificates = length(local.proxy_ssl_certificates) == 0 ? null : local.proxy_ssl_certificates ssl_policy = var.https_proxy_config.ssl_policy url_map = google_compute_region_url_map.default.id diff --git a/modules/net-lb-app-int/urlmap.tf b/modules/net-lb-app-int/urlmap.tf index 4c02a9297..b6de37ee9 100644 --- a/modules/net-lb-app-int/urlmap.tf +++ b/modules/net-lb-app-int/urlmap.tf @@ -27,7 +27,7 @@ resource "google_compute_region_url_map" "default" { project = var.project_id region = var.region name = var.name - description = var.description + description = var.urlmap_config.description default_service = ( var.urlmap_config.default_service == null ? null : lookup( local.backend_ids, diff --git a/modules/net-lb-app-int/variables-backend-service.tf b/modules/net-lb-app-int/variables-backend-service.tf index f4fd669e1..fbd89f8af 100644 --- a/modules/net-lb-app-int/variables-backend-service.tf +++ b/modules/net-lb-app-int/variables-backend-service.tf @@ -19,6 +19,8 @@ variable "backend_service_configs" { description = "Backend service level configuration." type = map(object({ + name = optional(string) + description = optional(string, "Terraform managed.") affinity_cookie_ttl_sec = optional(number) connection_draining_timeout_sec = optional(number) health_checks = optional(list(string), ["default"]) diff --git a/modules/net-lb-app-int/variables-health-check.tf b/modules/net-lb-app-int/variables-health-check.tf index a51994ecf..a20d0e085 100644 --- a/modules/net-lb-app-int/variables-health-check.tf +++ b/modules/net-lb-app-int/variables-health-check.tf @@ -19,6 +19,7 @@ variable "health_check_configs" { description = "Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage." type = map(object({ + name = optional(string) check_interval_sec = optional(number) description = optional(string, "Terraform managed.") enable_logging = optional(bool, false) diff --git a/modules/net-lb-app-int/variables-urlmap.tf b/modules/net-lb-app-int/variables-urlmap.tf index 0ea313dab..3a1ddda64 100644 --- a/modules/net-lb-app-int/variables-urlmap.tf +++ b/modules/net-lb-app-int/variables-urlmap.tf @@ -19,6 +19,7 @@ variable "urlmap_config" { description = "The URL map configuration." type = object({ + description = optional(string, "Terraform managed.") default_service = optional(string) default_url_redirect = optional(object({ host = optional(string) diff --git a/modules/net-lb-app-int/variables.tf b/modules/net-lb-app-int/variables.tf index 54ba0694d..a81e5853d 100644 --- a/modules/net-lb-app-int/variables.tf +++ b/modules/net-lb-app-int/variables.tf @@ -48,6 +48,8 @@ variable "group_configs" { variable "https_proxy_config" { description = "HTTPS proxy configuration." type = object({ + name = optional(string) + description = optional(string, "Terraform managed.") certificate_manager_certificates = optional(list(string)) ssl_policy = optional(string) }) @@ -213,6 +215,7 @@ variable "ssl_certificates" { type = object({ certificate_ids = optional(list(string), []) create_configs = optional(map(object({ + name = optional(string) certificate = string private_key = string })), {}) diff --git a/modules/net-lb-ext/README.md b/modules/net-lb-ext/README.md index 1d45eadbe..428b5ac84 100644 --- a/modules/net-lb-ext/README.md +++ b/modules/net-lb-ext/README.md @@ -202,17 +202,17 @@ For deploying changes to load balancer configuration please refer to [net-lb-app | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [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) | | {} | +| [name](variables.tf#L202) | Name used for all resources. | string | ✓ | | +| [project_id](variables.tf#L207) | Project id where resources will be created. | string | ✓ | | +| [region](variables.tf#L212) | GCP region. | string | ✓ | | +| [backend_service_config](variables.tf#L17) | Backend service level configuration. | object({…}) | | {} | +| [backends](variables.tf#L68) | Load balancer backends. | list(object({…})) | | [] | +| [description](variables.tf#L79) | Optional description used for resources. | string | | "Terraform managed." | +| [forwarding_rules_config](variables.tf#L85) | The optional forwarding rules configuration. | map(object({…})) | | {…} | +| [group_configs](variables.tf#L101) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | map(object({…})) | | {} | +| [health_check](variables.tf#L112) | Name of existing health check to use, disables auto-created health check. | string | | null | +| [health_check_config](variables.tf#L118) | 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#L196) | Labels set on resources. | map(string) | | {} | ## Outputs diff --git a/modules/net-lb-ext/main.tf b/modules/net-lb-ext/main.tf index 27dd19675..88588d06d 100644 --- a/modules/net-lb-ext/main.tf +++ b/modules/net-lb-ext/main.tf @@ -55,7 +55,7 @@ resource "google_compute_region_backend_service" "default" { project = var.project_id region = var.region name = coalesce(var.backend_service_config.name, var.name) - description = var.description + description = var.backend_service_config.description load_balancing_scheme = "EXTERNAL" protocol = var.backend_service_config.protocol health_checks = [local.health_check] diff --git a/modules/net-lb-ext/variables.tf b/modules/net-lb-ext/variables.tf index a048cd178..a62b0eb39 100644 --- a/modules/net-lb-ext/variables.tf +++ b/modules/net-lb-ext/variables.tf @@ -31,6 +31,7 @@ variable "backend_service_config" { locality_lb_policy = optional(string) log_sample_rate = optional(number) name = optional(string) + description = optional(string, "Terraform managed.") port_name = optional(string) protocol = optional(string, "UNSPECIFIED") session_affinity = optional(string) diff --git a/modules/net-lb-int/README.md b/modules/net-lb-int/README.md index 57dc6786b..5ed7b40a9 100644 --- a/modules/net-lb-int/README.md +++ b/modules/net-lb-int/README.md @@ -374,20 +374,20 @@ One other issue is a `Provider produced inconsistent final plan` error which is | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [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. Also set `health_check_config = null` when cross-referencing an health check from another load balancer module to avoid a Terraform error. | 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 | +| [name](variables.tf#L188) | Name used for all resources. | string | ✓ | | +| [project_id](variables.tf#L193) | Project id where resources will be created. | string | ✓ | | +| [region](variables.tf#L198) | GCP region. | string | ✓ | | +| [vpc_config](variables.tf#L224) | VPC-level configuration. | object({…}) | ✓ | | +| [backend_service_config](variables.tf#L17) | Backend service level configuration. | object({…}) | | {} | +| [backends](variables.tf#L53) | Load balancer backends. | list(object({…})) | | [] | +| [description](variables.tf#L64) | Optional description used for resources. | string | | "Terraform managed." | +| [forwarding_rules_config](variables.tf#L70) | The optional forwarding rules configuration. | map(object({…})) | | {…} | +| [group_configs](variables.tf#L86) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | map(object({…})) | | {} | +| [health_check](variables.tf#L98) | Name of existing health check to use, disables auto-created health check. Also set `health_check_config = null` when cross-referencing an health check from another load balancer module to avoid a Terraform error. | string | | null | +| [health_check_config](variables.tf#L104) | 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#L182) | Labels set on resources. | map(string) | | {} | +| [service_attachments](variables.tf#L203) | PSC service attachments, keyed by forwarding rule. | map(object({…})) | | null | +| [service_label](variables.tf#L218) | Optional prefix of the fully qualified forwarding rule name. | string | | null | ## Outputs diff --git a/modules/net-lb-int/main.tf b/modules/net-lb-int/main.tf index 1b1996a57..201d1e3eb 100644 --- a/modules/net-lb-int/main.tf +++ b/modules/net-lb-int/main.tf @@ -70,7 +70,7 @@ resource "google_compute_region_backend_service" "default" { project = var.project_id region = var.region name = coalesce(var.backend_service_config.name, var.name) - description = var.description + description = var.backend_service_config.description load_balancing_scheme = "INTERNAL" protocol = var.backend_service_config.protocol network = var.vpc_config.network diff --git a/modules/net-lb-int/variables.tf b/modules/net-lb-int/variables.tf index 0f0f22ae2..5df659c0a 100644 --- a/modules/net-lb-int/variables.tf +++ b/modules/net-lb-int/variables.tf @@ -31,6 +31,7 @@ variable "backend_service_config" { })) log_sample_rate = optional(number) name = optional(string) + description = optional(string, "Terraform managed.") protocol = optional(string, "UNSPECIFIED") session_affinity = optional(string) timeout_sec = optional(number) diff --git a/modules/net-lb-proxy-int/README.md b/modules/net-lb-proxy-int/README.md index 276c383fe..95e298385 100644 --- a/modules/net-lb-proxy-int/README.md +++ b/modules/net-lb-proxy-int/README.md @@ -334,21 +334,21 @@ For deploying changes to load balancer configuration please refer to [net-lb-app | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [name](variables.tf#L198) | Load balancer name. | string | ✓ | | -| [project_id](variables.tf#L267) | Project id. | string | ✓ | | -| [region](variables.tf#L272) | The region where to allocate the ILB resources. | string | ✓ | | -| [vpc_config](variables.tf#L292) | VPC-level configuration. | object({…}) | ✓ | | +| [name](variables.tf#L201) | Load balancer name. | string | ✓ | | +| [project_id](variables.tf#L270) | Project id. | string | ✓ | | +| [region](variables.tf#L275) | The region where to allocate the ILB resources. | string | ✓ | | +| [vpc_config](variables.tf#L295) | VPC-level configuration. | object({…}) | ✓ | | | [address](variables.tf#L17) | Optional IP address used for the forwarding rule. | string | | null | -| [backend_service_config](variables.tf#L23) | Backend service level configuration. | object({…}) | | {} | -| [description](variables.tf#L75) | Optional description used for resources. | string | | "Terraform managed." | -| [global_access](variables.tf#L82) | Allow client access from all regions. | bool | | null | -| [group_configs](variables.tf#L88) | Optional unmanaged groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [health_check](variables.tf#L100) | Name of existing health check to use, disables auto-created health check. | string | | null | -| [health_check_config](variables.tf#L106) | Optional auto-created health check configurations, 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) | | {} | -| [neg_configs](variables.tf#L203) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | -| [port](variables.tf#L261) | Port. | number | | 80 | -| [service_attachment](variables.tf#L277) | PSC service attachment. | object({…}) | | null | +| [backend_service_config](variables.tf#L23) | Backend service level configuration. | object({…}) | | {} | +| [description](variables.tf#L77) | Optional description used for resources. | string | | "Terraform managed." | +| [global_access](variables.tf#L84) | Allow client access from all regions. | bool | | null | +| [group_configs](variables.tf#L90) | Optional unmanaged groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | +| [health_check](variables.tf#L102) | Name of existing health check to use, disables auto-created health check. | string | | null | +| [health_check_config](variables.tf#L108) | Optional auto-created health check configurations, 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) | | {} | +| [neg_configs](variables.tf#L206) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | +| [port](variables.tf#L264) | Port. | number | | 80 | +| [service_attachment](variables.tf#L280) | PSC service attachment. | object({…}) | | null | ## Outputs diff --git a/modules/net-lb-proxy-int/backend-service.tf b/modules/net-lb-proxy-int/backend-service.tf index e6aa07a28..93481a955 100644 --- a/modules/net-lb-proxy-int/backend-service.tf +++ b/modules/net-lb-proxy-int/backend-service.tf @@ -38,8 +38,8 @@ resource "google_compute_region_backend_service" "default" { provider = google-beta project = var.project_id region = var.region - name = var.name - description = var.description + name = coalesce(var.backend_service_config.name, var.name) + description = var.backend_service_config.description affinity_cookie_ttl_sec = var.backend_service_config.affinity_cookie_ttl_sec connection_draining_timeout_sec = var.backend_service_config.connection_draining_timeout_sec health_checks = [local.health_check] diff --git a/modules/net-lb-proxy-int/health-check.tf b/modules/net-lb-proxy-int/health-check.tf index 5ec01c255..8e44dc5c2 100644 --- a/modules/net-lb-proxy-int/health-check.tf +++ b/modules/net-lb-proxy-int/health-check.tf @@ -32,7 +32,7 @@ resource "google_compute_region_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) region = var.region description = local.hc.description check_interval_sec = local.hc.check_interval_sec diff --git a/modules/net-lb-proxy-int/variables.tf b/modules/net-lb-proxy-int/variables.tf index 119265d24..4e8db0b05 100644 --- a/modules/net-lb-proxy-int/variables.tf +++ b/modules/net-lb-proxy-int/variables.tf @@ -23,6 +23,8 @@ variable "address" { variable "backend_service_config" { description = "Backend service level configuration." type = object({ + name = optional(string) + description = optional(string, "Terraform managed.") affinity_cookie_ttl_sec = optional(number) connection_draining_timeout_sec = optional(number) health_checks = optional(list(string), ["default"]) @@ -106,6 +108,7 @@ variable "health_check" { variable "health_check_config" { description = "Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage." type = object({ + name = optional(string) check_interval_sec = optional(number) description = optional(string, "Terraform managed.") enable_logging = optional(bool, false) diff --git a/tests/modules/net_lb_app_ext/examples/http-https-redirect.yaml b/tests/modules/net_lb_app_ext/examples/http-https-redirect.yaml index 73b8ec0f4..f4a4b65aa 100644 --- a/tests/modules/net_lb_app_ext/examples/http-https-redirect.yaml +++ b/tests/modules/net_lb_app_ext/examples/http-https-redirect.yaml @@ -52,7 +52,7 @@ values: prefix_redirect: null redirect_response_code: MOVED_PERMANENTLY_DEFAULT strip_query: false - description: Terraform managed. + description: URL redirect for glb-test-0. header_action: [] host_rule: [] name: glb-test-0-redirect From c551c5b2783a2dd15e99ab1dbdbc8f3736eeeed3 Mon Sep 17 00:00:00 2001 From: kovagoadam Date: Fri, 18 Jul 2025 13:58:29 +0200 Subject: [PATCH 2/2] Add support for quotas to project-factory module (#3242) * Add support for quotas to project-factory module * Updated embeded definition in net-vpc-factory --- modules/net-vpc-factory/factory-project.tf | 1 + .../factory-projects-object.tf | 1 + .../schemas/network-project.schema.json | 56 +++++++++++++++++++ .../factory-projects-object.tf | 1 + modules/project-factory/main.tf | 1 + .../schemas/project.schema.json | 53 ++++++++++++++++++ 6 files changed, 113 insertions(+) diff --git a/modules/net-vpc-factory/factory-project.tf b/modules/net-vpc-factory/factory-project.tf index f28949aa5..521220f84 100644 --- a/modules/net-vpc-factory/factory-project.tf +++ b/modules/net-vpc-factory/factory-project.tf @@ -45,4 +45,5 @@ module "projects" { iam_by_principals_additive = each.value.iam_by_principals_additive org_policies = each.value.org_policies project_reuse = each.value.project_reuse + quotas = each.value.quotas } diff --git a/modules/net-vpc-factory/factory-projects-object.tf b/modules/net-vpc-factory/factory-projects-object.tf index 15fa9d7d6..8a49660fd 100644 --- a/modules/net-vpc-factory/factory-projects-object.tf +++ b/modules/net-vpc-factory/factory-projects-object.tf @@ -302,6 +302,7 @@ locals { try(v.logging_data_access, null), local.__projects_config.data_defaults.logging_data_access ) + quotas = try(v.quotas, {}) }) } # tflint-ignore: terraform_unused_declarations diff --git a/modules/net-vpc-factory/schemas/network-project.schema.json b/modules/net-vpc-factory/schemas/network-project.schema.json index 37e9d02b8..b795ca16c 100644 --- a/modules/net-vpc-factory/schemas/network-project.schema.json +++ b/modules/net-vpc-factory/schemas/network-project.schema.json @@ -137,6 +137,9 @@ }, "iam_by_principals_additive": { "$ref": "#/$defs/iamByPrincipals" + }, + "quotas": { + "$ref": "#/$defs/quotas" } } }, @@ -1498,6 +1501,59 @@ } } } + }, + "quotas": { + "title": "Quotas", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^[a-zA-Z0-9_-]+$": { + "type": "object", + "additionalProperties": false, + "required": [ + "service", + "quota_id", + "preferred_value" + ], + "properties": { + "service": { + "type": "string" + }, + "quota_id": { + "type": "string" + }, + "preferred_value": { + "type": "number" + }, + "dimensions": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "justification": { + "type": "string" + }, + "contact_email": { + "type": "string" + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "ignore_safety_checks": { + "type": "string", + "enum": [ + "QUOTA_DECREASE_BELOW_USAGE", + "QUOTA_DECREASE_PERCENTAGE_TOO_HIGH", + "QUOTA_SAFETY_CHECK_UNSPECIFIED" + ] + } + } + } + } } } } \ No newline at end of file diff --git a/modules/project-factory/factory-projects-object.tf b/modules/project-factory/factory-projects-object.tf index 15fa9d7d6..8a49660fd 100644 --- a/modules/project-factory/factory-projects-object.tf +++ b/modules/project-factory/factory-projects-object.tf @@ -302,6 +302,7 @@ locals { try(v.logging_data_access, null), local.__projects_config.data_defaults.logging_data_access ) + quotas = try(v.quotas, {}) }) } # tflint-ignore: terraform_unused_declarations diff --git a/modules/project-factory/main.tf b/modules/project-factory/main.tf index b6af6aab4..cec1067eb 100644 --- a/modules/project-factory/main.tf +++ b/modules/project-factory/main.tf @@ -121,6 +121,7 @@ module "projects" { perimeter_bridges = each.value.vpc_sc.perimeter_bridges is_dry_run = each.value.vpc_sc.is_dry_run } + quotas = each.value.quotas } module "projects-iam" { diff --git a/modules/project-factory/schemas/project.schema.json b/modules/project-factory/schemas/project.schema.json index 15ab12e98..e2c765ed0 100644 --- a/modules/project-factory/schemas/project.schema.json +++ b/modules/project-factory/schemas/project.schema.json @@ -197,6 +197,59 @@ } } }, + "quotas": { + "title": "Quotas", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^[a-zA-Z0-9_-]+$": { + "type": "object", + "additionalProperties": false, + "required": [ + "service", + "quota_id", + "preferred_value" + ], + "properties": { + "service": { + "type": "string" + }, + "quota_id": { + "type": "string" + }, + "preferred_value": { + "type": "number" + }, + "dimensions": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "justification": { + "type": "string" + }, + "contact_email": { + "type": "string" + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "ignore_safety_checks": { + "type": "string", + "enum": [ + "QUOTA_DECREASE_BELOW_USAGE", + "QUOTA_DECREASE_PERCENTAGE_TOO_HIGH", + "QUOTA_SAFETY_CHECK_UNSPECIFIED" + ] + } + } + } + } + }, "parent": { "type": "string" },