hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.33k stars 1.73k forks source link

Can't remove attributes inside all_instances_config on google_compute_region_instance_group_manager #15688

Open edwardmedia opened 1 year ago

edwardmedia commented 1 year ago

Community Note

Terraform Version

Affected Resource(s)

Terraform Configuration Files

resource "google_compute_instance_template" "appserver" {
  name           = "appserver-template"
  machine_type   = "e2-medium"
  region = "us-west1"

  disk {
    source_image = data.google_compute_image.my_image.self_link
    auto_delete  = true
    boot         = true
  }

  network_interface {
    network = "default"
  }
}

resource "google_compute_region_instance_group_manager" "appserver" {
  provider = google-beta
  name = "appserver-igm"

  base_instance_name         = "app"
  region                     = "us-west1"
  distribution_policy_zones  = ["us-west1-a", "us-west1-b"]

  version {
    instance_template = google_compute_instance_template.appserver.self_link_unique
  }
  all_instances_config {.      <----- can't update by remove below attributes
/*
    metadata = {
      metadata_key = "metadata_value"
    }
    labels = {
      label_key = "label_value"
    }
*/
  }
}

With a PATCH request, the API does nothing

 ---[ REQUEST ]---------------------------------------
 PATCH /compute/beta/projects/myproject/regions/us-west1/instanceGroupManagers/appserver-igm
 Host: compute.googleapis.com
 {
  "allInstancesConfig": {
   "properties": {
    "labels": null,
    "metadata": null
   }
  },
  "fingerprint": "my8NjOSfB44="
 }

b/298256272

b/312433534

askubis commented 7 months ago

I see this issue, I agree with the problem. I will work on solving this. In the meantime I suggest the workaround by changing to useless values, e.g. when you want to delete all metadata, you might instead use metadata = { useless_key = "useless_value" }

I'll let you know when the original option works

askubis commented 5 months ago

It does work now. Sorry for the inconvenience.

askubis commented 5 months ago

please test and close this issue when test is successful