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

Addition of coalescelist in v17.15.0 breaks create_eks option #1575

Closed
arkose-jbridgstock opened this issue Sep 8, 2021 · 2 comments · Fixed by #1576
Closed

Addition of coalescelist in v17.15.0 breaks create_eks option #1575

arkose-jbridgstock opened this issue Sep 8, 2021 · 2 comments · Fixed by #1576

Comments

@arkose-jbridgstock
Copy link

arkose-jbridgstock commented Sep 8, 2021

Description

Line 11 of fargate.tf was changed on 6th September for "Added ability to pass different subnets for fargate and the cluster" using a coalescelist.

Coalescelist works only if there is at least one variable in the lists to coalesce. This excludes it from being passed variables with nothing in them when create_eks is set to False, as the coalescelist requires calculation at plan, and errors.

create_eks is used as a flag to disable the creation of EKS environments, as a work around to the more typical count. However, this no longer works if variables for a subnet are not supplied.

  • Terraform:
    Terraform v1.0.3
    on darwin_amd64
  • Provider(s):

Terraform v1.0.3
on darwin_amd64

  • provider registry.terraform.io/hashicorp/aws v3.57.0
  • provider registry.terraform.io/hashicorp/cloudinit v2.2.0
  • provider registry.terraform.io/hashicorp/helm v2.3.0
  • provider registry.terraform.io/hashicorp/kubernetes v2.4.1
  • provider registry.terraform.io/hashicorp/local v2.1.0
  • provider registry.terraform.io/hashicorp/null v3.1.0
  • provider registry.terraform.io/hashicorp/template v2.2.0
  • provider registry.terraform.io/newrelic/newrelic v2.7.5
  • provider registry.terraform.io/terraform-aws-modules/http v2.4.1
  • Module:
    terraform-aws-modules/eks/aws 17.15.0 affected, 17.14.0 is not.

Reproduction

Steps to reproduce the behavior:
Build two terraform files which use the eks module to provision an EKS cluster. Set one of them to create_eks = False and give an empty list for the subnets and fargate_subnets (which defaults to an empty list). Set the other with a populated subnet list.

Running a plan or apply, watch it error with:
Error: Error in function call │ │ on .terraform/modules/eks_cluster_ap_southeast_1.eks/fargate.tf line 11, in module "fargate": │ 11: subnets = coalescelist(var.fargate_subnets, var.subnets) │ ├──────────────── │ │ var.fargate_subnets is empty list of string │ │ var.subnets is empty list of string │ │ Call to function "coalescelist" failed: no non-null arguments.

Yes. I have switched to the appropriate workspace

Yes, cleared local cache.

Code Snippet to Reproduce

module "eks" {
source = "terraform-aws-modules/eks/aws"
create_eks = var.create_eks

cluster_name = var.cluster_name
cluster_version = var.cluster_version
enable_irsa = true
vpc_id = one(data.aws_vpc.eks_vpc..id)
subnets = flatten(data.aws_subnet_ids.worker_subnets.
.ids)
write_kubeconfig = false
(removed the rest)

You can see that we are using a lookup in order to get the subnets for each region. The lookup is controlled by the create_eks variable as well (see below), so with that set to false, there's nothing which is sent through.

data "aws_vpc" "eks_vpc" {
count = local.create_eks_count
tags = {
Name = var.vpc_name
}
}

data "aws_subnet_ids" "worker_subnets" {
count = local.create_eks_count
vpc_id = one(data.aws_vpc.eks_vpc.*.id)
tags = {
Tier = "Private"
}
}

Expected behavior

Prior to v17.15.0, the create_eks flag would stop an EKS environment from being created as a substitute for the count option which is not viable as per the module's documentation. By supplying an empty variable for the subnet, terraform would continue to run, as it does not need to create anything.

Actual behavior

v17.15.0 causes terraform to exit with the error 'Call to function "coalescelist" failed: no non-null arguments.' even when create_eks is set to False. So one must supply a subnet even if the EKS module is not expected to be created.

Pinning the module version to v17.14.0 results in the error message going away and a successful deployment.

Terminal Output Screenshot(s)

Error: Error in function call

│ on .terraform/modules/eks_cluster_ap_southeast_1.eks/fargate.tf line 11, in module "fargate":
│ 11: subnets = coalescelist(var.fargate_subnets, var.subnets)
│ ├────────────────
│ │ var.fargate_subnets is empty list of string
│ │ var.subnets is empty list of string

│ Call to function "coalescelist" failed: no non-null arguments.

Additional context

The documentation does state that the input is required, but it defeats the purpose of the create_eks variable if subnets are required for regions where you aren't actually wanting to create an EKS cluster.

@antonbabenko
Copy link
Member

Thanks for opening this detailed issue report.

I've just fixed it in #1576, v17.16.0 has been just released.

Currently, this module does require a bit too much when create_eks = true but it should not. It is something I am planning to improve during next week.

@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 18, 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.

2 participants