Multi line string variable

Hi,

We have been using Terraform EKS module and trying to parametrize ‘eks_managed_node_groups’ values based on the development and production environment as we have the same code base. We have used file() and variable approaches but both resulted in the error.

varibales.tf

variable "eks_cluster_nodegroups" {
  description = "Nodegroups of the EKS cluster"
}

.tfvars

eks_cluster_nodegroups = <<EOF
{
    ng-1 = {
      min_size     = 1
      max_size     = 2
      desired_size = 1

      instance_types = ['t3.small']
      capacity_type  = 'SPOT' //ON_DEMAND
    }
}
EOF

eks.tf

module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = "~> 18.0"
.....
.....
eks_managed_node_groups = var.eks_cluster_nodegroups
.....
}

Does anyone know how to fix this issue?

Thank you.

EKS module: Terraform Registry

Hi @bhaumik,

It looks like you want to assign some structured data to the eks_cluster_nodegroups variable, but in your tfvars file you are just assigning a string.

Try assigning the variable value like so:

eks_cluster_nodegroups = {
    ng-1 = {
      min_size     = 1
      max_size     = 2
      desired_size = 1

      instance_types = ["t3.small"]
      capacity_type  = "SPOT" //ON_DEMAND
    }
}
1 Like

Thank you so much @jbardin. It worked like a charm.