Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASM module erroring out on a count var #1259

Closed
pramodsetlur opened this issue May 18, 2022 · 1 comment
Closed

ASM module erroring out on a count var #1259

pramodsetlur opened this issue May 18, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@pramodsetlur
Copy link

pramodsetlur commented May 18, 2022

TL;DR

Error: Invalid count argument

  on .terraform/modules/gke_cluster.asm_managed_control_plane.cpr/main.tf line 57, in resource "random_id" "cache":
  57:   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.

Expected behavior

No response

Observed behavior

No response

Terraform Configuration

# Managed ASM inside GKE
module "asm_managed_control_plane" {
  depends_on = [
    google_container_cluster.gke_cluster
  ]
  count = var.asm_managed_control_plane_enabled == true ? 1 : 0
  source                    = "github.com/terraform-google-modules/terraform-google-kubernetes-engine//modules/asm?ref=v21.0.0"
  project_id                = var.project_id
  cluster_name              = var.cluster_name
  cluster_location          = var.region
  enable_cni                = true
  enable_fleet_registration = true
  enable_mesh_feature       = false
}

# The above depends on the below GKE cluster resource.

resource "google_container_cluster" "gke_cluster" {
  provider = google-beta

  name     = var.cluster_name
  location = var.region
  .
  .
  .
}

Terraform Version

Terraform version: "0.14.8"

Additional information

I was initially pointing to master and then updated it to v21.0.0 after #1189 was merged and released. It had been working last week when I created a new cluster with managed ASM control plane, but facing this error now.

@pramodsetlur pramodsetlur added the bug Something isn't working label May 18, 2022
@bharathkkb
Copy link
Member

Hi @pramodsetlur
I believe this is due to the depends_on block in the asm module.

 depends_on = [
    google_container_cluster.gke_cluster
  ]

#1189 works around this by making the GKE module cluster_name output a computed attribute. You can use the GKE module instead of the google_container_cluster resource or follow a similar approach of making the cluster_name computed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants