[bug] csi-external-snapshotter terraform error
dejwsz opened this issue · 2 comments
Describe the bug
First fresh install goes OK, but later after another apply I have this:
│ Error: Invalid for_each argument
│
│ on .terraform/modules/eks_addons.eks-aws-addons/modules/aws/csi-external-snapshotter.tf line 38, in resource "kubectl_manifest" "csi-external-snapshotter":
│ 38: for_each = local.csi-external-snapshotter.enabled ? { for v in local.csi-external-snapshotter_apply : lower(join("/", compact([v.data.apiVersion, v.data.kind, lookup(v.data.metadata, "namespace", ""), v.data.metadata.name]))) => v.content } : {}
│ ├────────────────
│ │ local.csi-external-snapshotter.enabled is true
│ │ local.csi-external-snapshotter_apply will be known only after apply
│
│ The "for_each" map includes keys derived from resource attributes that
│ cannot be determined until apply, and so Terraform cannot determine the
│ full set of keys that will identify the instances of this resource.
│
│ When working with unknown values in for_each, it's better to define the map
│ keys statically in your configuration and place apply-time results only in
│ the map values.
│
│ Alternatively, you could use the -target planning option to first apply
│ only the resources that the for_each value depends on, and then apply a
│ second time to fully converge.
╵
ERRO[0059] Terraform invocation failed in /Users/dejw/devel/dornach-aws-nonprod/environments/dornach_nonprod/eks
ERRO[0059] 1 error occurred:
* exit status 1
What is the current behavior?
TF error after another apply with csi external snapshotter
How to reproduce? Please include a code sample if relevant.
Add cso external spanshotter - deploy it for a first time - it should be OK - and then do the next TF apply and the error should come up.
What's the expected behavior?
No TF error after consecutive TF apply commands
Are you able to fix this problem and submit a PR? Link here if you have already.
Environment details
- Affected module version: csi-external-snapshotter
- OS: MacOS
- Terraform version: 1.3.5
- Kubernetes version: 1.21
- terraform-kubernetes-addons: 11.0.0
Any other relevant info
Was this as a first install ? Which version of TF/TG ?
At that time finally I used fixed version 6.1.0 of csi-external-snapshotter and I just used null_resource and kubectl to install it via yaml specs from the repo. Later I just injected fixed version as sidecar do EBS CSI controller. And it worked like that OK. I did not investigate csi-external-snapshotter.tf csi-external-snapshotter.tf due to lack of time then.