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.36k stars 1.75k forks source link

`cloud_run_v2_service`: attributes updated with `null` on every plan #20399

Open BBBmau opened 2 days ago

BBBmau commented 2 days ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.9.0 on

Affected Resource(s)

google_cloud_run_v2_service

Terraform Configuration

resource "google_cloud_run_v2_service" "default" {
  project             = "hc-5948a71742894b4e927b7fd629a"
  name                = "cloudrun-service"
  location            = "us-central1"
  deletion_protection = false
  ingress             = "INGRESS_TRAFFIC_ALL"

  template {
    scaling {
      min_instance_count = 0
    }

    containers {
      image = "us-docker.pkg.dev/cloudrun/container/hello"
      resources {
        limits = {
          memory = "1Gi"
        }
      }
    }
  }
}

Debug Output

Terraform will perform the following actions:

  # google_cloud_run_v2_service.default will be updated in-place
  ~ resource "google_cloud_run_v2_service" "default" {
        id                      = "projects/hc-5948a71742894b4e927b7fd629a/locations/us-central1/services/cloudrun-service"
        name                    = "cloudrun-service"
        # (31 unchanged attributes hidden)

      ~ template {
            # (9 unchanged attributes hidden)

          ~ containers {
                name        = null
                # (5 unchanged attributes hidden)

              ~ resources {
                  ~ limits            = {
                      - "cpu"    = "1000m" -> null
                        # (1 unchanged element hidden)
                    }
                    # (2 unchanged attributes hidden)
                }

                # (2 unchanged blocks hidden)
            }

          ~ scaling {
              - max_instance_count = 100 -> null
                # (1 unchanged attribute hidden)
            }
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Expected Behavior

no diff should be present.

Actual Behavior

attributes should not be updated to be null

Steps to reproduce

  1. terraform apply
  2. terraform apply

Important Factoids

after looking into this we could potentially solve this by including a diff suppress function for template.containers.resources.limits as well as mark template.scaling.max_instance_count as a client side default value of 100.

References

No response

b/380093176

ggtisc commented 1 day ago

Confirmed permadiff issue with the shared configuration when a terraform plan is executed