diff --git a/modules/net-lb-app-ext/README.md b/modules/net-lb-app-ext/README.md index 21a22c64d..be91c2d0f 100644 --- a/modules/net-lb-app-ext/README.md +++ b/modules/net-lb-app-ext/README.md @@ -1069,7 +1069,7 @@ After provisioning this change, and verifying that the new certificate is provis | [neg_configs](variables.tf#L117) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | | [protocol](variables.tf#L213) | Protocol supported by this load balancer. | string | | "HTTP" | | [ssl_certificates](variables.tf#L226) | 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({…}) | | {…} | +| [urlmap_config](variables-urlmap.tf#L19) | The URL map configuration. | object({…}) | | {…} | | [use_classic_version](variables.tf#L243) | Use classic Global Load Balancer. | bool | | true | ## Outputs diff --git a/modules/net-lb-app-ext/urlmap.tf b/modules/net-lb-app-ext/urlmap.tf index d215fdabc..3a6e8888b 100644 --- a/modules/net-lb-app-ext/urlmap.tf +++ b/modules/net-lb-app-ext/urlmap.tf @@ -36,6 +36,31 @@ resource "google_compute_url_map" "default" { ) ) + dynamic "default_custom_error_response_policy" { + for_each = ( + var.urlmap_config.default_custom_error_response_policy == null + ? [] + : [var.urlmap_config.default_custom_error_response_policy] + ) + iterator = p + content { + error_service = p.value.error_service == null ? null : lookup( + local.backend_ids, + p.value.error_service, + p.value.error_service + ) + dynamic "error_response_rule" { + for_each = coalesce(p.value.error_response_rules, []) + iterator = r + content { + match_response_codes = r.value.match_response_codes + path = r.value.path + override_response_code = r.value.override_response_code + } + } + } + } + dynamic "default_route_action" { for_each = ( var.urlmap_config.default_route_action == null @@ -261,6 +286,30 @@ resource "google_compute_url_map" "default" { ) description = m.value.description name = m.key + dynamic "default_custom_error_response_policy" { + for_each = ( + m.value.default_custom_error_response_policy == null + ? [] + : [m.value.default_custom_error_response_policy] + ) + iterator = p + content { + error_service = p.value.error_service == null ? null : lookup( + local.backend_ids, + p.value.error_service, + p.value.error_service + ) + dynamic "error_response_rule" { + for_each = coalesce(p.value.error_response_rules, []) + iterator = r + content { + match_response_codes = r.value.match_response_codes + path = r.value.path + override_response_code = r.value.override_response_code + } + } + } + } dynamic "default_route_action" { for_each = ( m.value.default_route_action == null @@ -472,6 +521,30 @@ resource "google_compute_url_map" "default" { path_rule.value.service, path_rule.value.service ) + dynamic "custom_error_response_policy" { + for_each = ( + path_rule.value.custom_error_response_policy == null + ? [] + : [path_rule.value.custom_error_response_policy] + ) + iterator = p + content { + error_service = p.value.error_service == null ? null : lookup( + local.backend_ids, + p.value.error_service, + p.value.error_service + ) + dynamic "error_response_rule" { + for_each = coalesce(p.value.error_response_rules, []) + iterator = r + content { + match_response_codes = r.value.match_response_codes + path = r.value.path + override_response_code = r.value.override_response_code + } + } + } + } dynamic "route_action" { for_each = ( path_rule.value.route_action == null diff --git a/modules/net-lb-app-ext/variables-urlmap.tf b/modules/net-lb-app-ext/variables-urlmap.tf index 2a3b2e711..e6ffe5551 100644 --- a/modules/net-lb-app-ext/variables-urlmap.tf +++ b/modules/net-lb-app-ext/variables-urlmap.tf @@ -19,6 +19,14 @@ variable "urlmap_config" { description = "The URL map configuration." type = object({ + default_custom_error_response_policy = optional(object({ + error_service = optional(string) + error_response_rules = optional(list(object({ + match_response_codes = optional(list(string)) + path = optional(string) + override_response_code = optional(number) + }))) + })) default_route_action = optional(object({ request_mirror_backend = optional(string) cors_policy = optional(object({ @@ -105,6 +113,14 @@ variable "urlmap_config" { }))) path_matchers = optional(map(object({ description = optional(string) + default_custom_error_response_policy = optional(object({ + error_service = optional(string) + error_response_rules = optional(list(object({ + match_response_codes = optional(list(string)) + path = optional(string) + override_response_code = optional(number) + }))) + })) default_route_action = optional(object({ request_mirror_backend = optional(string) cors_policy = optional(object({ @@ -186,6 +202,14 @@ variable "urlmap_config" { path_rules = optional(list(object({ paths = list(string) service = optional(string) + custom_error_response_policy = optional(object({ + error_service = optional(string) + error_response_rules = optional(list(object({ + match_response_codes = optional(list(string)) + path = optional(string) + override_response_code = optional(number) + }))) + })) route_action = optional(object({ request_mirror_backend = optional(string) cors_policy = optional(object({