terraform-google-modules / terraform-google-lb-http

Creates a global HTTP load balancer for Compute Engine by using forwarding rules
https://registry.terraform.io/modules/terraform-google-modules/lb-http/google
Apache License 2.0
312 stars 356 forks source link

Feature to ignore changes to backend services #74

Closed artazar closed 4 years ago

artazar commented 4 years ago

Hi,

I am using the Google LB Terraform module to create an LB with empty backend services that get automatically populated later on by Google's AutoNEG feature: https://github.com/GoogleCloudPlatform/gke-autoneg-controller

The issue here is that backends are created outside of terraform, so when this is done, the next run of Terraform plan intends to destroy them.

It would be nice to have an optional variable for the module to enable ignore_changes for backends specifically to make use of this feature.

Thanks!

TF configuration in use:

module "global-loadbalancer" {
  source  = "GoogleCloudPlatform/lb-http/google"
  version = "3.0.0"
  project = var.project_id
  name    = "global-loadbalancer"

  ssl         = true
  private_key = file("key")
  certificate = file("cert")

  firewall_networks = ["c0"]
  firewall_projects = [var.host_project_id]

  target_tags = []

  url_map        = google_compute_url_map.url-map.self_link
  create_url_map = false

  // We create empty backends to populate them automatically with autoneg feature
  // https://github.com/GoogleCloudPlatform/gke-autoneg-controller
  backends = {

    "frontendapi" = {
      description                     = null
      protocol                        = "HTTP"
      port                            = 8080
      port_name                       = "http"
      timeout_sec                     = 10
      connection_draining_timeout_sec = null
      enable_cdn                      = false
      health_check                    = local.health_check
      groups = []
    }
  }
}
morgante commented 4 years ago

I agree this could be quite useful and should be a use case we support.

However, instead of directly exposing an option to ignore changes and using it together with an empty groups list, I think we might want to automatically ignore changes on any backend without any groups.