Allowing disabling logging and configuring optional fields in LB backend services (#3940)
* fix(modules): allow disabling logging and configuring optional fields in LB backend services
Replaced 'log_sample_rate' (number) with 'log_config' (object) in all Load Balancer Backend Service modules. This allows explicitly disabling logging ('enable = false') and configuring advanced options like 'optional_mode' and 'optional_fields', resolving infinite plan drift and the inability to disable logging.
Affected modules:
- net-lb-app-ext-regional
- net-lb-app-ext
- net-lb-app-int-cross-region
- net-lb-app-int
- net-lb-ext
- net-lb-int
- net-lb-proxy-int
Added test cases and updated documentation.
Fixes #3914
* style: format variables files with terraform fmt
* docs: add critical linting rule for AI agents to GEMINI.md
This commit is contained in:
committed by
GitHub
parent
16c245f43b
commit
bf9ccb7547
@@ -205,16 +205,16 @@ For deploying changes to load balancer configuration please refer to [net-lb-app
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [name](variables.tf#L198) | Name used for all resources. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L203) | Project id where resources will be created. | <code>string</code> | ✓ | |
|
||||
| [region](variables.tf#L208) | GCP region. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L203) | Name used for all resources. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L208) | Project id where resources will be created. | <code>string</code> | ✓ | |
|
||||
| [region](variables.tf#L213) | GCP region. | <code>string</code> | ✓ | |
|
||||
| [backend_service_config](variables.tf#L17) | Backend service level configuration. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [backends](variables.tf#L68) | Load balancer backends. | <code>list(object({…}))</code> | | <code>[]</code> |
|
||||
| [forwarding_rules_config](variables.tf#L79) | The optional forwarding rules configuration. | <code>map(object({…}))</code> | | <code>{…}</code> |
|
||||
| [group_configs](variables.tf#L95) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | <code>map(object({…}))</code> | | <code>{}</code> |
|
||||
| [health_check](variables.tf#L108) | Name of existing health check to use, disables auto-created health check. | <code>string</code> | | <code>null</code> |
|
||||
| [health_check_config](variables.tf#L114) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | <code>object({…})</code> | | <code>{…}</code> |
|
||||
| [labels](variables.tf#L192) | Labels set on resources. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [backends](variables.tf#L73) | Load balancer backends. | <code>list(object({…}))</code> | | <code>[]</code> |
|
||||
| [forwarding_rules_config](variables.tf#L84) | The optional forwarding rules configuration. | <code>map(object({…}))</code> | | <code>{…}</code> |
|
||||
| [group_configs](variables.tf#L100) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | <code>map(object({…}))</code> | | <code>{}</code> |
|
||||
| [health_check](variables.tf#L113) | Name of existing health check to use, disables auto-created health check. | <code>string</code> | | <code>null</code> |
|
||||
| [health_check_config](variables.tf#L119) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | <code>object({…})</code> | | <code>{…}</code> |
|
||||
| [labels](variables.tf#L197) | Labels set on resources. | <code>map(string)</code> | | <code>{}</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
@@ -102,10 +102,12 @@ resource "google_compute_region_backend_service" "default" {
|
||||
}
|
||||
|
||||
dynamic "log_config" {
|
||||
for_each = var.backend_service_config.log_sample_rate == null ? [] : [""]
|
||||
for_each = var.backend_service_config.log_config == null ? [] : [""]
|
||||
content {
|
||||
enable = true
|
||||
sample_rate = var.backend_service_config.log_sample_rate
|
||||
enable = var.backend_service_config.log_config.enable
|
||||
sample_rate = var.backend_service_config.log_config.sample_rate
|
||||
optional_mode = var.backend_service_config.log_config.optional_mode
|
||||
optional_fields = var.backend_service_config.log_config.optional_fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,18 @@ variable "backend_service_config" {
|
||||
ratio = optional(number)
|
||||
}))
|
||||
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)
|
||||
timeout_sec = optional(number)
|
||||
log_config = optional(object({
|
||||
enable = optional(bool)
|
||||
sample_rate = optional(number)
|
||||
optional_mode = optional(string)
|
||||
optional_fields = optional(list(string))
|
||||
}))
|
||||
name = optional(string)
|
||||
description = optional(string, "Terraform managed.")
|
||||
port_name = optional(string)
|
||||
protocol = optional(string, "UNSPECIFIED")
|
||||
session_affinity = optional(string)
|
||||
timeout_sec = optional(number)
|
||||
})
|
||||
default = {}
|
||||
nullable = false
|
||||
|
||||
Reference in New Issue
Block a user