Terraform-provider-google: Perma-diff google_cloud_run_service

Created on 5 Feb 2020  ·  7Comments  ·  Source: hashicorp/terraform-provider-google


Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave _+1_ or _me too_ comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v0.12.20
+ provider.google v3.7.0
+ provider.google-beta v3.7.0
+ provider.null v2.1.2
+ provider.random v2.2.1
+ provider.template v2.1.2

Affected Resource(s)

  • google_cloud_run_service

Expected Behavior

No perma-diff

Actual Behavior

terraform apply repeatedly produces the plan:

~ resource "google_cloud_run_service" "default" {

      # ...

      ~ template {
          - metadata {
              - annotations = {
                  - "autoscaling.knative.dev/maxScale" = "1000"
                } -> null
              - generation  = 0 -> null
              - labels      = {} -> null
            }

          ~ spec {
              - container_concurrency = 80 -> null
                service_account_name  = "..."

              ~ containers {
                    args    = []
                    command = []
                    image   = "..."

                  - resources {
                      - limits   = {
                          - "cpu"    = "1000m"
                          - "memory" = "256M"
                        } -> null
                      - requests = {} -> null
                    }
                }
            }
        }

      # ...

    }

Steps to Reproduce

  1. terraform apply
  2. terraform apply
bug upstream

All 7 comments

I am interested in working on this issue. Is this issue appropriate for beginners?

@menarulalam thank you for your interest! However I took a quick look at this yesterday and I think it's going to be a bit more involved of a fix as the fields that are now coming back from the API are complex types that might need some custom logic.

The root cause here is that CloudRun has started returning default values that weren't previously exposed. This means that all versions of this resource are currently affected. I have reached out to their team to see if it's possible to address this in the API. (b/148965108)

It's further complicated that these fields appear to be affected by a bug in Terraform core so I'm unable to fix it in the provider at this time. Marking these fields as computed will still continue to show a permadiff. The Terraform bug is https://github.com/hashicorp/terraform/issues/24044.

I'll open the PR but will wait to merge until 1 of the teams is able to work on the upstream bug.

I have learned that this is expected Terraform behavior and have adjusted my PR to be able to handle deeply nested default values. The API team is unable to address the upstream issue at this time so it looks like the fix will be coming in 3.8.0.

In the mean time you can manually work around this permadiff by manually specifying the defaulted values in your config. Here's an example with the defaults explicit:

resource "google_cloud_run_service" "default" {
  name     = "tftest-cloudrun"
  location = "us-central1"

  template {
    metadata {
      annotations = {
        "autoscaling.knative.dev/maxScale" = "1000" //explicit
      }
    }
    spec {
      container_concurrency = 80 //explicit
      containers {
        image = "gcr.io/cloudrun/hello"
        resources {
          limits = {
            "cpu"    = "1000m" //explicit
            "memory" = "256M" //explicit
          }
        }
      }
    }
  }

  traffic {
    percent         = 100
    latest_revision = true
  }
}

Thanks @chrisst. Yes, this is exactly the workaround I use to silence the perma-diff for now.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings