Modular Global HTTP Load Balancer for GCE using forwarding rules.
module "gce-lb-http" {
source = "GoogleCloudPlatform/lb-http/google"
name = "group-http-lb"
target_tags = ["${module.mig1.target_tags}", "${module.mig2.target_tags}"]
backends = {
"0" = [
{ group = "${module.mig1.instance_group}" },
{ group = "${module.mig2.instance_group}" }
],
}
backend_params = [
# health check path, port name, port number, timeout seconds.
"/,http,80,10"
]
}
Figure 1. diagram of terraform resources
google_compute_global_forwarding_rule.http
: The global HTTP forwarding rule.google_compute_global_forwarding_rule.https
: The global HTTPS forwarding rule created whenssl
istrue
.google_compute_target_http_proxy.default
: The HTTP proxy resource that binds the url map. Created when inputssl
isfalse
.google_compute_target_https_proxy.default
: The HTTPS proxy resource that binds the url map. Created when inputssl
istrue
.google_compute_ssl_certificate.default
: The certificate resource created when inputssl
istrue
.google_compute_url_map.default
: The default URL map resource when inputurl_map
is not provided.google_compute_backend_service.default.*
: The backend services created for each of thebackend_params
elements.google_compute_http_health_check.default.*
: Health check resources create for each of the backend services.google_compute_firewall.default-hc
: Firewall rule created for each of the backed services to alllow health checks to the instance group.