terraform-google-modules/terraform-google-vm

Autoscaling signal empty condition

Minakhalil91 opened this issue · 1 comments

TL;DR

When using the following autoscaling signal, an empty condition is created, which causes a UI error " This item contains one or more errors "

 metric {
  name   = "compute.googleapis.com/instance/cpu/utilization"
  target = 0.75
  type   = "GAUGE"

Expected behavior

Expected Metrics signal to look like this:

B9XJaqZ29LSHQdW

Observed behavior

Instead, there is an empty condition that is causing a UI issue.

image

Terraform Configuration

resource "google_compute_autoscaler" "default" {
  provider = google-beta

  name   = "my-autoscaler"
  zone   = "us-central1-f"
  target = google_compute_instance_group_manager.default.id

  autoscaling_policy {
    max_replicas    = 5
    min_replicas    = 1
    cooldown_period = 60

    metric {
      name   = "compute.googleapis.com/instance/cpu/utilization"
      target = 0.75
      type   = "GAUGE"
    }
  }
}

resource "google_compute_instance_template" "default" {
  provider = google-beta

  name           = "my-instance-template"
  machine_type   = "e2-medium"
  can_ip_forward = false

  tags = ["foo", "bar"]

  disk {
    source_image = data.google_compute_image.debian_9.id
  }

  network_interface {
    network = "default"
  }

  metadata = {
    foo = "bar"
  }

  service_account {
    scopes = ["userinfo-email", "compute-ro", "storage-ro"]
  }
}

resource "google_compute_target_pool" "default" {
  provider = google-beta

  name = "my-target-pool"
}

resource "google_compute_instance_group_manager" "default" {
  provider = google-beta

  name = "my-igm"
  zone = "us-central1-f"

  version {
    instance_template = google_compute_instance_template.default.id
    name              = "primary"
  }

  target_pools       = [google_compute_target_pool.default.id]
  base_instance_name = "autoscaler-sample"
}

data "google_compute_image" "debian_9" {
  provider = google-beta

  family  = "debian-11"
  project = "debian-cloud"
}

provider "google-beta" {
  region = "us-central1"
  zone   = "us-central1-a"

}

Terraform Version

Terraform v1.5.1

Additional information

Terraform might be accounting for the aggregator field and adding the extra = that is causing the issue. If i click edit from the UI and turn on and off the aggregator the extra condition is removed and the issue is fixed.

image