Why terraform plan reports helm_release's "set' blocks as changing if they are not?

I have a helm_release like this:

resource "helm_release" "prometheus" {
  name = "prometheus"
  namespace = kubernetes_namespace.prometheus.metadata[0].name
  wait = true
  repository = "https://kubernetes-charts.storage.googleapis.com/"
  chart = "prometheus"
  version = var.prometheus_chart_version

  dynamic "set" {
    for_each = var.volumes
    content {
      name  = "${set.key}.persistentVolume.enabled"
      value = "true"
    }
  }

  dynamic "set" {
    for_each = var.volumes
    content {
      name  = "${set.key}.persistentVolume.existingClaim"
      value = kubernetes_persistent_volume_claim.volumeclaims[set.key].metadata[0].name
    }
  }

  set {
    name  = "server.ingress.enabled"
    value = "true"
  }

  set {
    name  = "server.ingress.hosts"
    value = "{prometheus.example.net/*}"
  }

  dynamic "set" {
    for_each = local.ingress_annotations

    content {
      name = "server.ingress.annotations.${replace(set.key,".", "\\.")}"
      value = set.value
      type = "string"
    }
  }

  dynamic "set"  {
    for_each = [ "server", "alertmanager", "pushgateway" ]
    content {
      name  = "${set.value}.service.annotations.external-dns\\.alpha\\.kubernetes\\.io/hostname"
      value = "prometheus-${set.value}.example.net."
    }
  }
}

When I do terraform plan it will report that more or less every set {} block has been deleted and added again like this:

  - set {
      - name  = "server.ingress.enabled" -> null
      - value = "true" -> null
    }
  + set {
      + name  = "server.ingress.enabled"
      + value = "true"
    }

There are many set {...} blocks and having to look at each of them event when they didn’t actually changed seems silly. Is there anything I can do so that terraform recognizes that there are indeed the same set {...} block?

Hi @ecerulm,

Are you saying that you see this happen when none of the set blocks have changed at all, or is it instead that some of the blocks have really changed but Terraform is additionally showing all of the ones that haven’t?

If it’s the second one, it seems like the plan renderer is not fully understanding the situation for some reason. I’m not sure there will be anything you could immediately do to improve that result, but there is some work underway to improve the plan rendering to eliminate some of these cases where it’s more verbose than it needs to be so hopefully this’ll get better as a result of that.

If it’s the first one, that sounds like a bug somewhere, but I’m not sure where. It might help if you are able to show the full output from terraform plan that’s showing the unexpected changes, in case there’s a clue in there.

I meant the second one. I changed a single set block but the in the generated plan looks like there ~10 changes.

I’ve opened a bug report https://github.com/hashicorp/terraform/issues/26084