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

`google_cloud_run_service` has flaky attributes #12397

Open ace-n opened 2 years ago

ace-n commented 2 years ago

Community Note

Terraform Version

Terraform 1.1.8; Go 1.17.2

Affected Resource(s)

Debug Output

  | Terraform used the selected providers to generate the following execution
  | plan. Resource actions are indicated with the following symbols:
  |   ~ update in-place
  | 
  | Terraform will perform the following actions:
  | 
  |   # google_cloud_run_service.default will be updated in-place
  |   ~ resource "google_cloud_run_service" "default" {
  |         id                         = "locations/us-central1/namespaces/<...>/services/<NAME>"
  |         name                       = "<NAME>"
  |         # (4 unchanged attributes hidden)
  | 
  | 
  |       ~ template {
  |           ~ metadata {
  |               ~ annotations = {
  |                   - "\"autoscaling.knative.dev/maxScale\""        = "100" -> null
  |                     # (2 unchanged elements hidden)
  |                 }
  |               + labels      = {}
  |                 # (1 unchanged attribute hidden)
  |             }
  | 
  |           ~ spec {
  |                 # (3 unchanged attributes hidden)
  | 
  |               ~ containers {
  |                   + args    = []
  |                   + command = []
  |                     # (1 unchanged attribute hidden)
  | 
  | 
  |                     # (2 unchanged blocks hidden)
  |                 }
  |             }
  |         }
  | 
  |         # (2 unchanged blocks hidden)
  |     }
  | 
  | Plan: 0 to add, 1 to change, 0 to destroy.

Observed Behavior

Flaky command and args properties

The template.spec.containers property requires command and args attributes (i.e. a default value is included) on update, but not on create.

Flaky labels property

A similar problem exists for template.metadata.labels.

Deleted annotations

The template.metadata.annotations block does not preserve the autoscaling.knative.dev/maxScale annotation.

Steps to Reproduce

  1. Run an initial terraform init, followed by a terraform apply.
  2. Run a second terraform apply.

Workaround

Specify the defaults for these properties manually.

References

b/272362086

ace-n commented 2 years ago

@edwardmedia was there any additional info you needed?

(I'm not sure why this is assigned to me. 🙂 )

ScottSuarez commented 2 years ago

Hi @ace-n, this is an unfortunate situation where an api isn't declarative friendly. Our team doesn't have the capacity to take this on currently.

As a work around look to using lifecycle rules to get around this. Specifically ignore_changes.