Skip to content

fix(modules): fix health check and backend service configs in net-lb-ext, net-lb-int, and net-lb-proxy-int - #297

Merged
Calvin-Cheng1 merged 1 commit into
mainfrom
fix/internal-lb-health-check-and-backend-refs
Oct 21, 2026
Merged

Calvin-Cheng1 merged 1 commit into
mainfrom
fix/internal-lb-health-check-and-backend-refs

Conversation

@aghassemlouei

@aghassemlouei aghassemlouei commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Description

  • Fix http2_health_check and ssl_health_check in modules/net-lb-ext/health-check.tf and modules/net-lb-int/health-check.tf to read attributes from local.hc.http2 and local.hc.ssl instead of local.hc.http and local.hc.tcp.
  • Guard local.health_check in modules/net-lb-proxy-int/main.tf with try(google_compute_region_health_check.default[0].self_link, null) and set health_checks = local.health_check == null ? null : [local.health_check] in modules/net-lb-proxy-int/backend-service.tf, removing unsupported connection_tracking_policy and failover_policy blocks and guarding nullable var.backend_service_config.backends and var.health_check_config validations in modules/net-lb-proxy-int/variables.tf.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Deployment & Compliance Impact

  • Applicable Regimes:
    • US Region Restricted (e.g., Access Policy constraint)
    • FedRAMP Moderate
    • FedRAMP High
    • DoD IL4
    • DoD IL5
    • General / All
  • NIST 800-53r5 Controls: SC-7, SC-12, SC-13, SC-28, AC-2, AC-3, AC-6, CM-2, CM-6

Checklist

Code Quality & Reusability

  • My code adheres to the Maximize Reusability principle. I have not redefined common elements and have reused existing base configurations and modules where possible.
  • I have checked that no existing module or configuration in modules/ or fast/stages-aw/ can be leveraged for this change.
  • My code follows the established naming conventions outlined in docs/naming-convention.md.

Documentation

  • I have updated the README.md of the modified module or blueprint.
  • I have added/updated documentation for inputs (variables) and outputs.

Security

  • My change adheres to GCP security best practices and the principle of least privilege.
  • I have ensured compliance with the targeted regime (FedRAMP Moderate, FedRAMP High, IL4, IL5, etc.).

Testing

  • I have tested my changes locally.
  • I have included details of my testing in this PR.

Testing Performed

  • Executed bash tools/run_tests.sh (all Python unit tests, shell syntax checks, shell unit tests, and CodeQL AST checks pass) and python3 tools/check_documentation.py modules/net-lb-ext modules/net-lb-int modules/net-lb-proxy-int.

@aghassemlouei aghassemlouei added Bug Something isn't working Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Status - Ready for Review labels Oct 20, 2026
@aghassemlouei
aghassemlouei force-pushed the fix/internal-lb-health-check-and-backend-refs branch from ad543ab to ab57c1e Compare October 20, 2026 15:06

@Calvin-Cheng1 Calvin-Cheng1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions here:

  1. modules/net-lb-ext/health-check.tf (lines 66–77 and 92–102): Apply the same health check fix here as in modules/net-lb-int/health-check.tf by pointing http2_health_check to local.hc.http2.* instead of local.hc.http.* and ssl_health_check to local.hc.ssl.* instead of local.hc.tcp.* (matching upstream Cloud Foundation Fabric). This fixes a null reference crash during Terraform plan/apply when configuring an http2 or ssl health check on an external load balancer, since local.hc.http and local.hc.tcp are null when another health check protocol is selected.
  2. modules/net-lb-proxy-int/main.tf (lines 44–48) and modules/net-lb-proxy-int/backend-service.tf (line 45): Guard local.health_check in main.tf with try(google_compute_region_health_check.default[0].self_link, null) and set health_checks = local.health_check == null ? null : [local.health_check] in backend-service.tf. While modules/net-lb-proxy-int/variables.tf now fixes Cannot iterate over null value when var.health_check_config = null, this prevents google_compute_region_health_check.default[0] from failing with an empty tuple index error when health checks are disabled (such as for PSC or Internet NEG backends).
  3. modules/net-lb-proxy-int/backend-service.tf (lines 59 and 73–93) and modules/net-lb-proxy-int/variables.tf (lines 36 and 44–56): Remove connection_tracking_policy, failover_policy, connection_tracking, failover_config, and backend.failover instead of fixing the ar.backend_service_config and local.bs_conntrack references inside connection_tracking_policy. This fixes both the undeclared reference errors in terraform validate and prevents GCP API errors if a user sets those options, since net-lb-proxy-int creates a proxy load balancer (INTERNAL_MANAGED) and GCP only supports connection tracking and failover policies on passthrough load balancers.

@aghassemlouei
aghassemlouei force-pushed the fix/internal-lb-health-check-and-backend-refs branch from ab57c1e to c574835 Compare October 20, 2026 22:33
@aghassemlouei aghassemlouei added Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Scope - Module Related to reusable Terraform modules in the modules directory and removed Scope - Modules labels Oct 20, 2026
@aghassemlouei
aghassemlouei force-pushed the fix/internal-lb-health-check-and-backend-refs branch from c574835 to 67ebb92 Compare October 20, 2026 22:57
@aghassemlouei
aghassemlouei force-pushed the fix/internal-lb-health-check-and-backend-refs branch from 67ebb92 to 6f015aa Compare October 20, 2026 23:26
@aghassemlouei
aghassemlouei force-pushed the fix/internal-lb-health-check-and-backend-refs branch 4 times, most recently from 686a110 to 347ebe0 Compare October 21, 2026 00:31
@aghassemlouei aghassemlouei changed the title fix(modules): fix health check and backend service references in net-lb-int and net-lb-proxy-int fix(modules): fix health check and backend service configs in net-lb-ext, net-lb-int, and net-lb-proxy-int Oct 21, 2026
@aghassemlouei

Copy link
Copy Markdown
Member Author

Thanks for the review @Calvin-Cheng1! All three items are addressed in commit 347ebe07:

  • Updated http2_health_check and ssl_health_check in modules/net-lb-ext/health-check.tf to read attributes from local.hc.http2 and local.hc.ssl so net-lb-ext and net-lb-int stay aligned.
  • Updated local.health_check in modules/net-lb-proxy-int/main.tf to use try(google_compute_region_health_check.default[0].self_link, null) and set health_checks = local.health_check == null ? null : [local.health_check] in modules/net-lb-proxy-int/backend-service.tf so var.health_check_config = null does not pass [null] to the provider.
  • Removed connection_tracking_policy and failover_policy from modules/net-lb-proxy-int/backend-service.tf, removed connection_tracking, failover_config, and backend.failover from modules/net-lb-proxy-int/variables.tf, and regenerated modules/net-lb-proxy-int/README.md via tools/tfdoc.py.

@aghassemlouei
aghassemlouei force-pushed the fix/internal-lb-health-check-and-backend-refs branch from 347ebe0 to fd6883d Compare October 21, 2026 02:20
@aghassemlouei
aghassemlouei force-pushed the fix/internal-lb-health-check-and-backend-refs branch from fd6883d to a965ce4 Compare October 21, 2026 03:00
@Calvin-Cheng1
Calvin-Cheng1 merged commit ad0370d into main Oct 21, 2026
21 checks passed
@Calvin-Cheng1
Calvin-Cheng1 deleted the fix/internal-lb-health-check-and-backend-refs branch October 21, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Scope - Module Related to reusable Terraform modules in the modules directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants