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.29k stars 1.72k forks source link

Workbench Instance - Metadata forces recreate #18469

Open kirksw opened 3 months ago

kirksw commented 3 months ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.8.5 on aarch64-apple-darwin

Affected Resource(s)

google_workbench_instance

Terraform Configuration

resource "google_workbench_instance" "default" {
  name     = "workbench-test"
  location = "europe-west1-b"

  gce_setup {
    machine_type = "n1-standard-4"

    service_accounts {
      email = google_service_account.default.email
    }

    metadata = {
      idle-timeout-seconds = "3600"
    }
}

Debug Output

Expected Behavior

Actual Behavior

Starts all instances on every apply, updates metadata.proxy-byoid-url to null.

Steps to reproduce

  1. terraform apply

Important Factoids

No response

References

No response

b/348498822

ggtisc commented 3 months ago

Confirmed issue!

After the resource was created when there aren't changes and ran a 2nd terraform apply it detects changes. This looks like a permadiff on proxy-byoid-url

kirksw commented 2 months ago

Confirmed issue!

After the resource was created when there aren't changes and ran a 2nd terraform apply it detects changes. This looks like a permadiff on proxy-byoid-url

I would say there are two issues, what you have referenced - but also the default desired state behavior, which will start or stop all the instances (no possibility to just stay in the current state)

bcreddy-gcp commented 2 months ago

The issue should be fixed with https://github.com/GoogleCloudPlatform/magic-modules/pull/10900

Verified by the following: Created a google_workbench_instance using the following config.

resource "google_workbench_instance" "default" {
  project = "<redacted>"
  name = "workbench-test"
  location = "us-west1-a"

  gce_setup {
    machine_type = "n1-standard-4"
    metadata = {
      idle-timeout-seconds = "3600"
    }
  }

}

terraform plan on the same config any number of times gave No changes. Your infrastructure matches the configuration..

Added desired_state = "ACTIVE" to the config. terraform plan on the same config any number of times gave No changes. Your infrastructure matches the configuration..

Updated desired_state = "STOPPED" in the config.

  ~ update in-place

Terraform will perform the following actions:

  # google_workbench_instance.default will be updated in-place
  ~ resource "google_workbench_instance" "default" {
      ~ desired_state        = "ACTIVE" -> "STOPPED"

terraform plan on the same config any number of times gave No changes. Your infrastructure matches the configuration..

Updated desired_state = "ACTIVE" in the config.

  ~ update in-place

Terraform will perform the following actions:

  # google_workbench_instance.default will be updated in-place
  ~ resource "google_workbench_instance" "default" {
      ~ desired_state        = "STOPPED" -> "ACTIVE"

terraform plan on the same config any number of times gave No changes. Your infrastructure matches the configuration..