-
Notifications
You must be signed in to change notification settings - Fork 93
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
Invalid count argument error #82
Comments
I can confirm that I am experiencing the same issue. Searches on the Internet indicates that this started happening to people after upgrading to Terraform version 0.13.x. |
I am encountering the same issue as well. Wondering if there is a quick workaround. This has blocked all our regular plan/apply routines. |
Experiencing the same issue while trying to provision Workload Identities with pre-existing KSAs using terraform-google-kubernetes-engine/tree/v12.0.0/modules/workload-identity.
|
Thanks for the reports everyone. So far I've been unable to replicate, but clearly it's an issue. @bharathkkb Have you run into this? |
@morgante yes, I was able to repro from the initial config and TF 0.13.5 module "foo" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0"
skip_download = "false"
}
module "bar" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0"
skip_download = "false"
depends_on = [module.foo]
} @kanekotic could you try using @davidmontoyago did |
This looks like a side effect of https://www.terraform.io/upgrade-guides/0-13.html#data-resource-reads-can-no-longer-be-disabled-by-refresh-false In a very simplified config, problem stems from
vs
|
will give it a try and let you know first thing on monday |
we are able to reproduce without a module level depends_on. Any other workarounds available? |
Hi @davearata-snorack |
Tried today with:
Issue still persists if |
module "apply-extra-manifests" {
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
version = "~> 2.0.2"
skip_download = true
cluster_name = var.cluster_name
cluster_location = var.location
project_id = var.project_id
kubectl_create_command = "kubectl apply ${local.extra_manifests}"
kubectl_destroy_command = "kubectl delete ${local.extra_manifests}"
} @bharathkkb this is an example of it not working without the |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days |
@bharathkkb Do you know if this is still a bug in new Terraform versions? |
@morgante this should still be an error with module depends_on as the data source eval will be pushed to apply time. I haven't encountered this with other cases but based on this comment, this is WAI. Considering we have been steadily reducing the usage of gcloud module we could also consider dropping the env var and requiring plumbing to support this. |
I'd like to avoid that, as I still prefer the env variable approach to having to plumb through variables. We should try to switch to native resources as much as possible though. |
Dear google team, faced the. same issue with kubectl-wrapper module
Error
|
@lubouski Can you try using |
any update regarding this? the problem still occurs in version 1.0.5. I've tried using as @zxpower. There's a parent module which has |
This works! Thanks. |
Having the same issue here; https://github.com/terraform-google-modules/terraform-google-cloud-operations Tested with TF version v0.15.3 and v1.0.4. |
What I did for now was just get all my relating repos offline, change the sources (so they point to the local files, and not remote github) and change the breaking line of code; In the locals dict, change the skip_download to true, instead of the if statement. That solves it for me. Don't want to lose any more time on this as well, and is fine for now. Note that this is not future proof, as you won't have the latest repo's. |
This worked for me. |
This is a possible workaround proposed by @barathkkb for an the gcloud module reporting an invalid count argument error. terraform-google-modules/terraform-google-gcloud#82 (comment)
This is a possible workaround proposed by @barathkkb for an the gcloud module reporting an invalid count argument error. terraform-google-modules/terraform-google-gcloud#82 (comment)
This is a possible workaround proposed by @barathkkb for an the gcloud module reporting an invalid count argument error. terraform-google-modules/terraform-google-gcloud#82 (comment)
@morgante Could we rename the According to a Terraform support article, Terraform can directly access environment variables with a |
I'm still getting this error on Terraform 1.2.5 and terraform module Error: Invalid count argument
on .terraform/modules/asm.cpr/main.tf line 57, in resource "random_id" "cache":
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. module "asm" {
source = "registry.terraform.io/terraform-google-modules/kubernetes-engine/google//modules/asm"
version = "21.2.0"
project_id = local.gcp_project_id
cluster_name = local.gke_cluster_name
cluster_location = module.gke.location
enable_cni = false
enable_fleet_registration = true
enable_mesh_feature = false
depends_on = [
module.gke
]
} Any help would be really appreciated. |
Hi @shawlz Could you try replacing |
@apeabody Yes, here is what I got
|
Hi @apeabody. I've run into the same issue with the workload-identity sub-module. I see the fix that you made to asm under Feature Request #121, adding a module_depends_on var to the module and wiring it in where you use kubectl-wrapper. I tried the same thing in my local workload-identity module and it fixed the problem. Could you please look into applying this to workload-identity? Am I going about requesting this the right way? Apologies if not. Thanks for a fantastically useful module. |
Hi @headegg - Thanks for reaching out! Typically I would suggest opening a fresh feature request, but not to worry as I've created the pull request for workload-identity which you can track here: terraform-google-modules/terraform-google-kubernetes-engine#1341 |
Thanks a million @apeabody. I'll bear that in mind in future. |
@apeabody When using module_depends_on on the asm module I get the following error:
This is the corresponding module usage:
Thanks for looking into this! 🙏 |
Hi @aablsk - Thanks for reaching out! It's bit more complicated than I expected, but you can track a potential workaround here: terraform-google-modules/terraform-google-kubernetes-engine#1354 |
Hi, the issue still exists when using the asm module ("terraform-google-modules/kubernetes-engine/google//modules/asm")
Could someone take a look into this? Thank you! Looks like the issue is within these two lines, where the terraform cannot determine the value of the boolean before running the script in |
Same issue here...
|
@bharathkkb or @apeabody , a colleague of mine has found a way to prevent this issue from happening when building dependency chains. Check out this repo: https://github.com/kingman/tf-dont-do-depends-on-module-demo/blob/main/demo-flow/README.md |
Currently getting an error when using the module:
Error
Module
Environment
The text was updated successfully, but these errors were encountered: