terraform-google-kubernetes-engine icon indicating copy to clipboard operation
terraform-google-kubernetes-engine copied to clipboard

(possibly) unneeded/unused `resource null_resource.module_depends_on` created

Open swapzero opened this issue 3 years ago • 1 comments

TL;DR

A possibly unneeded/unused resource is created when calling the module and it's the only one created as part of that module call (enabled = false because defaults are used for parameters that affect enabled value)

Resource:


$ terraform state show ...

resource "null_resource" "module_depends_on" {
    id       = "4730592283587992509"
    triggers = {
        "value" = "2"
    }
}

The code that creates the resource is here and it gets called when module gcloud_delete_default_kube_dns_configmap is called.

Apparently, it is the only resource that doesn't use enabled module option, therefore it gets created even if enabled is false and occasionally shows changes when the nodepools are added/removed.

Expected behavior

The resource should also use enabled flag to avoid creation (module options that affect enabled are on defaults so in my case enabled = false)

 resource "null_resource" "module_depends_on" {
-  count = length(var.module_depends_on) > 0 ? 1 : 0
+  count = (length(var.module_depends_on) > 0 && var.enabled) ? 1 : 0
   triggers = {
     value = length(var.module_depends_on)
  }
}

Observed behavior

The only resource that is created as part of the submodule call and it has no effect alone.

Terraform Configuration

module "gke" {
  source  = "terraform-google-modules/kubernetes-engine/google//modules/beta-private-cluster-update-variant"
  version = "20.0.0"
...
}

Terraform Version

0.15.5

Additional information

No response

swapzero avatar Apr 01 '22 17:04 swapzero

Since the resource has no impact, I don't think this is a major issue either way. You're welcome to file a PR on the gcloud repo.

morgante avatar Apr 01 '22 19:04 morgante