CodexBloom - Programming Q&A Platform

Terraform AWS EKS Cluster scenarios to Launch with 'InvalidParameter' scenarios When Setting NodeGroup IAM Role

👀 Views: 58 💬 Answers: 1 📅 Created: 2025-06-08
terraform aws eks HCL

I'm performance testing and I'm attempting to set up I'm trying to figure out Hey everyone, I'm running into an issue that's driving me crazy. I'm trying to provision an EKS cluster on AWS using Terraform, but the deployment fails with an 'InvalidParameter' behavior when specifying the IAM role for the node group. My Terraform code looks like this: ```hcl provider "aws" { region = "us-west-2" } resource "aws_iam_role" "eks_node_group_role" { name = "eks-node-group-role" assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = "sts:AssumeRole" Effect = "Allow" Principal = { Service = "ec2.amazonaws.com" } } ] }) } resource "aws_eks_cluster" "my_cluster" { name = "my-cluster" role_arn = aws_iam_role.eks_cluster_role.arn vpc_config { subnet_ids = aws_subnet.my_subnets[*].id } } resource "aws_eks_node_group" "my_node_group" { cluster_name = aws_eks_cluster.my_cluster.name node_group_name = "my-node-group" node_role_arn = aws_iam_role.eks_node_group_role.arn subnet_ids = aws_subnet.my_subnets[*].id scaling_config { desired_size = 2 max_size = 3 min_size = 1 } } ``` I created the IAM role with the correct trust policy for EC2, but I'm still getting the following behavior when running `terraform apply`: ``` behavior: behavior launching EKS Node Group: InvalidParameter: The role arn:aws:iam::123456789012:role/eks-node-group-role is invalid. ``` I've ensured that the IAM role has the necessary policies attached, particularly `AmazonEKSWorkerNodePolicy`, `AmazonEC2ContainerRegistryReadOnly`, and `AmazonEKS_CNI_Policy`. Additionally, I double-checked that the IAM role has been created before the node group is attempted to be provisioned. I’ve tried reapplying the configuration multiple times, but the behavior continues. Could anyone point out what might be causing this scenario? Are there any best practices for configuring IAM roles with EKS in Terraform that I might be overlooking? This is part of a larger web app I'm building. Thanks in advance! Is there a better approach? I recently upgraded to Hcl stable. I'd be grateful for any help. This issue appeared after updating to Hcl LTS. What am I doing wrong?