CodexBloom - Programming Q&A Platform

Terraform Module for EKS: how to to Set Node Group Auto-Scaling Parameters Correctly

👀 Views: 68 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-08
terraform aws-eks auto-scaling HCL

Hey everyone, I'm running into an issue that's driving me crazy. I'm working on a Terraform configuration to set up an Amazon EKS cluster with auto-scaling for the node groups, using Terraform version 1.4.0. I've defined a module for the EKS setup, and while the cluster itself is created successfully, I'm working with issues with the auto-scaling settings for the node group. When I attempt to apply the configuration, I get the following behavior: ``` behavior: expected node_group.0.scaling_config[0].desired_size to be between 1 and 100, got 0 ``` I've set the `desired_size` parameter in my `aws_eks_node_group` resource to 2, but it seems to default to 0 upon applying. Here is a snippet of my configuration: ```hcl module "eks" { source = "terraform-aws-modules/eks/aws" cluster_name = "my-cluster" cluster_version = "1.21" node_groups = { eks_nodes = { desired_capacity = 2 max_capacity = 5 min_capacity = 1 instance_type = "t3.medium" key_name = "my-key" tags = { Name = "EKS Node Group" } } } } ``` I've also tried manually specifying `scaling_config` within the `aws_eks_node_group` resource, but that didn't resolve the scenario either. Just to make sure, I verified that my IAM roles have the required permissions for EKS and auto-scaling. The Terraform plan runs without errors, but the apply step fails. I'm not sure if I'm missing something in the configuration or if there's a specific ordering that's affecting the desired size setting. Any insights on how to troubleshoot this or recommendations on best practices for configuring EKS node groups would be greatly appreciated! Thanks in advance! I'm working on a web app that needs to handle this. How would you solve this? My team is using Hcl for this application. Thanks, I really appreciate it! Am I missing something obvious?