Invalid value for "v" parameter: cannot convert "" to number; given string terraform eks modules

Viewed 5009

I've created following eks cluster with terraform eks module.

module "myeks" {
  source          = "terraform-aws-modules/eks/aws"
  cluster_name    = var.project
  version         = "7.0.1"
  cluster_version = var.eks_version
  subnets         = data.aws_subnet_ids.subnet_ids.ids
  vpc_id          = var.vpc_id

  worker_groups = [
    {
      name          = "worker-group-1"
      instance_type = "m5.large"
      asg_max_size  = 2
    }
  ]
}

But problem is when I run that code in gitlabci, I've encountered following error message.

Error: Invalid function argument
  on .terraform/modules/myeks/data.tf line 6, in locals:
   6:     var.worker_ami_name_filter_windows : "Windows_Server-2019-English-Core-EKS_Optimized-${tonumber(var.cluster_version) >= 1.14 ? var.cluster_version : 1.14}-*"
    |----------------
    | var.cluster_version is ""
Invalid value for "v" parameter: cannot convert "" to number; given string
must be a decimal representation of a number.
Error: Your query returned no results. Please change your search criteria and try again.
  on .terraform/modules/myeks/data.tf line 25, in data "aws_ami" "eks_worker":
  25: data "aws_ami" "eks_worker" {

But when I do terraform plan in local machine, it's working fine.

That's my tfvars.

vpc_id        = "vpc-xxxxx"
environment   = "dev"
eks_version   = "1.17"
project       = "mypro"
1 Answers

Based on the comments.

The issue was due to the fact that var.eks_version was empty. This was caused by not mapping .tfvars in gitlabci.

The solution was to add the missing mapping in gitlabci.

Related