All the resources are destroy, however scrips throw error line next one
Error: Error in function call
on .terraform/modules/eks/terraform-aws-modules-terraform-aws-eks-9c3d222/local.tf line 6, in locals:
6: cluster_security_group_id = coalesce(
7:
8:
9:
|----------------
| aws_security_group.cluster is empty tuple
| var.cluster_security_group_id is ""
Call to function "coalesce" failed: no non-null, non-empty-string arguments.
Error: Error in function call
on .terraform/modules/eks/terraform-aws-modules-terraform-aws-eks-9c3d222/local.tf line 22, in locals:
22: worker_security_group_id = coalesce(
23:
24:
25:
|----------------
| aws_security_group.workers is empty tuple
| var.worker_security_group_id is ""
Call to function "coalesce" failed: no non-null, non-empty-string arguments.
terraform plan -out=apply.plan
terraform apply apply.plan
terraform plan -out=destroy.plan -destroy
terraform should not throw this error
yes, just next lines to both error functions
cluster_security_group_id = coalesce(
join("", aws_security_group.cluster.*.id),
var.cluster_security_group_id,
"aws-eks" <-- line that fixes
)
worker_security_group_id = coalesce(
join("", aws_security_group.workers.*.id),
var.worker_security_group_id,
"aws-eks" <-- line that fixes
)
When i add those two lines, terraform does not throw error if I apply destroy plan
Not quite sure what fix you are proposing but could you make a PR?
FWIW this is happening for me too when infrastructure is not fully destroyed, due in part to https://github.com/terraform-aws-modules/terraform-aws-eks/issues/285.
Probably not an option for most but I only am able to workaround it by deleting the local and remote state.
I would not call this module problem... according to the docs this is how it should behave.
Call to function "coalesce" failed: no non-null, non-empty-string arguments.
Again, problem with Terraform, not this module...
I believe terraform 0.12 has actually changed the behavior of coalesce() when all the inputs are empty. Before v0.12, when all inputs were empty, an empty string was returned. Starting from v0.12, it is considered an error.
Here's a terraform issue stating this.
Unfortunately, terraform's own documentation on coalesce() doesn't say anything about this case. It only lists examples where a non-empty value is found.
We just migrated to terraform 0.12 and are affected by this bug. Would it be possible to release 5.1.1 with this fix instead of having to wait for the next major release?
@marcelloromani you can always use a commit ID like this: [email protected]:terraform-aws-modules/terraform-aws-eks.git?ref=xxxxx"
Hi @max-rocket-internet
I tried that approach but it doesn't work:
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "c9986f5e01c785875cb1e9cfa21ba195ef1bbab7"
[...]
gives this error:
Error: Invalid version constraint
on eks-cluster.tf line 3, in module "eks":
3: version = "c9986f5e01c785875cb1e9cfa21ba195ef1bbab7"
This string does not use correct version constraint syntax.
I tried different ways of referring to the commit to no avail.
try
source = "git::https://github.com/terraform-aws-modules/terraform-aws-eks.git?ref= c9986f5e01c785875cb1e9cfa21ba195ef1bbab7" as @max-rocket-internet suggested more or less...
Thanks @confiq that line worked:
module "eks" {
source = "git::https://github.com/terraform-aws-modules/terraform-aws-eks.git?ref=c9986f5e01c785875cb1e9cfa21ba195ef1bbab7"
[...]
I've just tested creating / destroy a cluster with that version and the coalesce() bug didn't appear.
Most helpful comment
@marcelloromani you can always use a commit ID like this:
[email protected]:terraform-aws-modules/terraform-aws-eks.git?ref=xxxxx"