Skip to content

Invalid count argument in workload-identity module #2339

@Khuman2

Description

@Khuman2

I use the module:

module "gitlab-runner-workload-identity" {
  source              = "terraform-google-modules/kubernetes-engine/google//modules/workload-identity"
  version             = "36.3.0"
  use_existing_k8s_sa = true
  cluster_name        = var.cluster_name
  location            = var.region
  name                = kubernetes_service_account.gitlab_runner.metadata[0].name
  namespace           = kubernetes_service_account.gitlab_runner.metadata[0].namespace
  project_id          = var.project_id
  roles               = [
    "roles/artifactregistry.writer"
  ]

  depends_on = [ kubernetes_service_account.gitlab_runner ]
}

After upgrading my modules I get error:

Error: Invalid count argument

 on .terraform/modules/gitlab-runner-workload-identity.annotate-sa/main.tf line 58, in resource "random_id" "cache":
58:   count = (!local.skip_download) ? 1 : 0
 
The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the
-target argument to first apply only the resources that the count depends on.

How can I get rid of this behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions