IaC Bazaar
Google CloudPlan-validated

Global External HTTPS Load Balancer

Global ALB with managed TLS certs, URL map, serverless/instance NEG backends, optional Cloud CDN and Cloud Armor policy.

terraformGCP#gcp

Compare Load Balancer across clouds →

gcp-http-load-balancerterraform v1.7

Verification

Plan-validated

Passed: module logic verified on a mocked plan — inputs, validation rules, conditional creation and outputs resolve (no real provider, no cloud).

Conformance

  • Static validation (fmt · validate · tflint)
  • Security scan: findings disclosed (Checkov)
  • Plan tests (mocked: validation rules · outputs)

Provenance

  • SHA-256 checksum
  • Signature (pending)

Functional

  • Live test pending (no cloud run yet)

Last verified 2026-06-28 · how we verify

Documentation

gcp-http-load-balancer

Global external HTTPS Application Load Balancer — GCP's most confusing surface (7+ interlocking resources) wired correctly in one module: static anycast IP, Google-managed TLS certificates, URL-map host/path routing to instance-group or NEG backends, optional Cloud CDN and Cloud Armor, plus an HTTP→HTTPS redirect listener. Works with Terraform and OpenTofu (>= 1.6), Google provider >= 7.0, < 8.0.

Secure defaults:

  • Modern EXTERNAL_MANAGED load-balancing scheme
  • SSL policy with MODERN profile and TLS 1.2 minimum
  • HTTPS-only: port 80 serves a 301 redirect (toggleable)
  • Cloud Armor attachment per backend when the policy is enabled
  • Backend request logging on (sample rate 1.0)

Usage

module "lb" {
  source = "./gcp-http-load-balancer"

  project_id      = "my-project"
  name            = "web"
  domains         = ["www.example.com"]
  default_backend = "app"

  backends = {
    app = {
      groups       = [{ group = google_compute_instance_group_manager.app.instance_group }]
      health_check = { port = 8080, request_path = "/healthz" }
    }
    api = {
      # Serverless NEG (Cloud Run): no health check, no timeout
      groups       = [{ group = google_compute_region_network_endpoint_group.run.id }]
      health_check = null
    }
  }

  host_rules = {
    api = {
      hosts           = ["api.example.com"]
      default_backend = "api"
    }
  }
}

Inputs

NameTypeDefaultDescription
project_idstringHost project (required)
namestringResource name prefix (required)
backendsmap(object)Backend services: groups, protocol, CDN, health check (required)
default_backendstringBackend key for unmatched traffic (required)
create_ip_addressbooltrueReserve a static global IP
ip_addressstringnullExisting IP when not creating one
domainslist(string)[]Domains for the managed certificate
ssl_certificateslist(string)[]Existing cert self links
ssl_policy_profilestringMODERNCOMPATIBLE/MODERN/RESTRICTED
min_tls_versionstringTLS_1_2Minimum TLS version
enable_quicboolfalseQUIC/HTTP3
enable_http_redirectbooltruePort-80 301 redirect
host_rulesmap(object){}Host/path routing rules
create_security_policyboolfalseCreate Cloud Armor policy
security_policy_rulesmap(object){}Armor rules (CEL expression or src_ip_ranges)
security_policy_default_actionstringallowCatch-all rule action
labelsmap(string){}Labels on address + forwarding rules

Outputs

ip_address, url_map_self_link, backend_service_self_links, managed_certificate_self_link, https_proxy_self_link, ssl_policy_self_link, security_policy_self_link, https_forwarding_rule, http_forwarding_rule.

Notes

  • Managed certificates stay in PROVISIONING until the domain's A/AAAA record points at the LB IP; budget up to ~30 minutes after DNS is correct. The cert name embeds a hash of the domain set, so changing domains replaces it via create-before-destroy without downtime.
  • Serverless NEGs (Cloud Run / App Engine / Cloud Functions): set health_check = null and leave timeout_sec unset — the platform manages both.
  • At least one of domains or ssl_certificates is required (plan-time check).
  • Instance-group backends default to UTILIZATION balancing; override per group with balancing_mode / max_rate_per_instance etc.

Requirements

  • Terraform or OpenTofu >= 1.6
  • hashicorp/google >= 7.0, < 8.0
  • API: compute.googleapis.com

Verification

Static-validated (fmt, validate, tflint). Live apply/destroy testing pending cloud sandbox availability — see catalog status.

License

Commercial — IaC Bazaar EULA. © IaC Bazaar. Original work (not derived from a third-party module).