terraform-google-lb-http
terraform-google-lb-http copied to clipboard
Creating non-classic Global HTTPS Load Balancing
TL;DR
This module seems to create a classic HTTPS load balancer, without any option to create the new Envoy-based load balancers. Is there a way to create the new Envoy-based load balancers using this module? Happy to contribute something but would need some guidance
Terraform Resources
No response
Detailed design
No response
Additional information
No response
This can be done by adding a variable to the variables.tf file called load_balancing_scheme , setting the default to EXTERNAL and modifying three resources to use that variable, see below. In your tfvars file or wherever you are defining your variables, set load_balancing_scheme = "EXTERNAL" for classic load balancer and load_balancing_scheme = "EXTERNAL_MANAGED" for the new Envoy load balancer. I fully tested this and it works like a champ.
resource "google_compute_global_forwarding_rule" "http" {
project = var.project
count = local.create_http_forward ? 1 : 0
name = var.name
target = google_compute_target_http_proxy.default[0].self_link
ip_address = local.address
port_range = "80"
load_balancing_scheme = var.load_balancing_scheme
}
resource "google_compute_global_forwarding_rule" "https" {
project = var.project
count = var.ssl ? 1 : 0
name = "${var.name}-https"
target = google_compute_target_https_proxy.default[0].self_link
ip_address = local.address
port_range = "443"
load_balancing_scheme = var.load_balancing_scheme
}
resource "google_compute_backend_service" "default" {
provider = google-beta
for_each = var.backends
project = var.project
name = "${var.name}-backend-${each.key}"
port_name = each.value.port_name
protocol = each.value.protocol
load_balancing_scheme = var.load_balancing_scheme
If someone forks this module and adds these fixes, that would be great. Or a maintainer could provide a timeline for when they will add this.