terraform-provider-google: Error: Provider produced inconsistent final plan

I see an error when dynamically trying to set the backends for the google_compute_backend_service. Usually works on second run, but this is not good.

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

2021/04/01 22:12:54 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2021/04/01 22:12:54 [INFO] Terraform version: 0.14.3
2021/04/01 22:12:54 [INFO] Go runtime version: go1.15.2
2021/04/01 22:12:54 [INFO] CLI args: []string{"/usr/local/bin/terraform", "version"}
2021/04/01 22:12:54 [DEBUG] Attempting to open CLI config file: /Users/juandiegopalomino/.terraformrc
2021/04/01 22:12:54 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021/04/01 22:12:54 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021/04/01 22:12:54 [DEBUG] ignoring non-existing provider search directory /Users/juandiegopalomino/.terraform.d/plugins
2021/04/01 22:12:54 [DEBUG] ignoring non-existing provider search directory /Users/juandiegopalomino/Library/Application Support/io.terraform/plugins
2021/04/01 22:12:54 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2021/04/01 22:12:54 [INFO] CLI command args: []string{"version"}
Terraform v0.14.3
+ provider registry.terraform.io/hashicorp/google v3.62.0
+ provider registry.terraform.io/hashicorp/helm v2.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/tls v3.1.0

Your version of Terraform is out of date! The latest version
is 0.14.9. You can update by downloading from https://www.terraform.io/downloads.html

Affected Resource(s)

google_compute_backend_service

Terraform Configuration Files

variable "layer_name" {
  description = "Layer name"
  type        = string
}

resource "google_compute_global_address" "load_balancer" {
  name    = "opta-${var.layer_name}"
}

resource "google_compute_health_check" "healthcheck" {
  name               = "opta-${var.layer_name}"
  http_health_check {
    port_specification = "USE_SERVING_PORT"
    request_path = "/healthz"
  }
}

data "google_compute_zones" "zones" {}

data "google_compute_network_endpoint_group" "http" {
  count = length(data.google_compute_zones.zones.names)
  name = "opta-${var.layer_name}-http"
  zone = data.google_compute_zones.zones.names[count.index]
  depends_on = [
    helm_release.ingress-nginx
  ]
}


data "google_compute_network_endpoint_group" "https" {
  count = length(data.google_compute_zones.zones.names)
  name = "opta-${var.layer_name}-https"
  zone = data.google_compute_zones.zones.names[count.index]
  depends_on = [
    helm_release.ingress-nginx
  ]
}

resource "google_compute_backend_service" "backend_service" {
  name        = "opta-${var.layer_name}"
  port_name   = "http"
  protocol    = "HTTP"

  health_checks = [google_compute_health_check.healthcheck.id]

  dynamic "backend" {
    for_each = local.negs
    content {
      balancing_mode = "RATE"
      max_rate_per_endpoint = 50
      group = backend.value
    }
  }
  depends_on = [helm_release.ingress-nginx] # A helm release that succeeded
}

Debug Output

https://gist.github.com/juandiegopalomino/b54500cc1bc98a6170d10322b818a481

Panic Output

Expected Behavior

No provider error

Actual Behavior

Error: Provider produced inconsistent final plan

Steps to Reproduce

  1. terraform apply

Important Factoids

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 8
  • Comments: 18 (2 by maintainers)

Most upvoted comments

serve_while_stale seems likely to be the root cause behind https://github.com/hashicorp/terraform-provider-google/issues/8939; hopefully fixing that will eliminate one of the contributing factors.