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

Call to function "coalesce" failed: no non-null, non-empty-string arguments. local.tf file #402

Closed
1 of 4 tasks
sppwf opened this issue Jun 20, 2019 · 10 comments · Fixed by #459
Closed
1 of 4 tasks

Comments

@sppwf
Copy link
Contributor

sppwf commented Jun 20, 2019

I have issues

I'm submitting a...

  • bug report
  • feature request
  • support request
  • kudos, thank you, warm fuzzy

What is the current behavior?

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.

If this is a bug, how to reproduce? Please include a code sample if relevant.

terraform plan -out=apply.plan
terraform apply apply.plan
terraform plan -out=destroy.plan -destroy

What's the expected behavior?

terraform should not throw this error

Are you able to fix this problem and submit a PR? Link here if you have already.

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
)

Environment details

  • Affected module version: 5.0.0
  • OS: Centos
  • Terraform version: 0.12.2

Any other relevant info

When i add those two lines, terraform does not throw error if I apply destroy plan

@max-rocket-internet
Copy link
Contributor

Not quite sure what fix you are proposing but could you make a PR?

@cantide5ga
Copy link

FWIW this is happening for me too when infrastructure is not fully destroyed, due in part to #285.

Probably not an option for most but I only am able to workaround it by deleting the local and remote state.

@confiq
Copy link
Contributor

confiq commented Jun 27, 2019

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...

@petrikero
Copy link
Contributor

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.

max-rocket-internet pushed a commit that referenced this issue Aug 6, 2019
* Replace coalesce() usage for locals with ternary operator. Fixes terraform errors during destroy when only empty strings were passed to coalesce().

* Update changelog.

* Fix formatting.
@marcelloromani
Copy link
Contributor

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?

@max-rocket-internet
Copy link
Contributor

@marcelloromani you can always use a commit ID like this: [email protected]:terraform-aws-modules/terraform-aws-eks.git?ref=xxxxx"

@marcelloromani
Copy link
Contributor

marcelloromani commented Sep 13, 2019

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.

@confiq
Copy link
Contributor

confiq commented Sep 13, 2019

try

source = "git::https://github.com/terraform-aws-modules/terraform-aws-eks.git?ref= c9986f5e01c785875cb1e9cfa21ba195ef1bbab7" as @max-rocket-internet suggested more or less...

@marcelloromani
Copy link
Contributor

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.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants