terraform-google-lb-http icon indicating copy to clipboard operation
terraform-google-lb-http copied to clipboard

Creating non-classic Global HTTPS Load Balancing

Open jawnsy opened this issue 3 years ago • 2 comments

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

jawnsy avatar Jul 21 '22 18:07 jawnsy

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

btbinaryjanitor avatar Jul 28 '22 21:07 btbinaryjanitor

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.

aleccool213 avatar Sep 22 '22 21:09 aleccool213