<p>I launched an EKS cluster using terraform <a href="https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest" rel="nofollow noreferrer">module</a></p>
<p>My template looks something like this:</p>
<pre><code>module &quot;eks&quot; {
source          = &quot;terraform-aws-modules/eks/aws&quot;
version         = &quot;17.20.0&quot;
cluster_name    = &quot;${var.cluster_name}&quot;
cluster_version = var.cluster_version
subnets         = [&quot;${var.public_subnet_1}&quot;, 
&quot;${var.public_subnet_2}&quot;,&quot;${var.public_subnet_3}&quot;]
vpc_id          = var.vpc_id
cluster_security_group_id = &quot;${var.master_sg_id}&quot;
worker_security_group_id =  &quot;${var.master_sg_id}&quot;
workers_additional_policies =[aws_iam_policy.siera_alb_ingress_controller_policy.arn]
workers_role_name = &quot;${var.cluster_name}-${var.environment}-${var.aws_region}-worker-role&quot;
map_roles = [
  {
  rolearn   = &quot;arn:aws:iam::${var.account_no}:role/${var.cluster_name}-${var.environment}-${var.aws_region}-worker-role&quot;
  username  = &quot;system:node:{{EC2PrivateDNSName}}&quot;
  groups    = [&quot;system:bootstrappers&quot;,&quot;system:nodes&quot;]
  },
  {
  rolearn   = &quot;arn:aws:sts::${var.account_no}:assumed-role/${var.assumed_role_1}&quot;
  username  = &quot;admin&quot;
  groups    = [&quot;system:masters&quot;,&quot;system:nodes&quot;,&quot;system:bootstrappers&quot;]
  },
  {
  rolearn  = &quot;arn:aws:sts::${var.account_no}:assumed-role/${var.assumed_role_2}&quot;
  username  = &quot;admin&quot;
  groups    = [&quot;system:masters&quot;,&quot;system:nodes&quot;,&quot;system:bootstrappers&quot;]
  }
]
  tags = {
    Purpose = &quot;${var.project}&quot;
    Environment = &quot;${var.environment}&quot;
  }

worker_groups_launch_template = [
{
  name                  = &quot;${var.cluster_name}-lt&quot;
  key_name              = &quot;${var.node_key}&quot;
  additional_userdata   = &lt;&lt;EOT
                          &quot;echo dummy&quot; 
                          EOT
  instance_type         = &quot;${var.node_size}&quot;
  asg_min_size          = 3
  asg_desired_capacity  = 3
  asg_max_size          = 5
  autoscaling_enabled   = true
  asg_force_delete      = true
  public_ip             = true
  enable_monitoring     = false
  root_volume_size      = 80
  suspended_processes   = [&quot;AZRebalance&quot;]
  tags = [
    {
      &quot;key&quot;                 = &quot;k8s.io/cluster-autoscaler/enabled&quot;
      &quot;propagate_at_launch&quot; = &quot;false&quot;
      &quot;value&quot;               = &quot;true&quot;
    },
    {
      &quot;key&quot;                 = &quot;k8s.io/cluster-autoscaler/${var.cluster_name}&quot;
      &quot;propagate_at_launch&quot; = &quot;false&quot;
      &quot;value&quot;               = &quot;true&quot;
    }
  ]
}
] 
manage_aws_auth = false 
}
</code></pre>
<p>As you can see I'm trying to add aws-auth configmap using map_roles.</p>
<p>After launching the cluster when I run <code>kubectl describe configmap -n kube-system aws-auth</code></p>
<p>It gives this error: <code>Error from server (NotFound): configmaps &quot;aws-auth&quot; not found</code></p>
<p>What am I missing? Please help</p>

Red Bottle
<p>Terraform needs to connect the the created cluster and use the cluster credentials to create the <code>aws-auth</code> configmap. Add this to the file that is creating the EKS cluster.</p>
<pre><code>data &quot;aws_eks_cluster&quot; &quot;default&quot; {
  name = module.eks.cluster_id
}

data &quot;aws_eks_cluster_auth&quot; &quot;default&quot; {
  name = module.eks.cluster_id
}

provider &quot;kubernetes&quot; {
  host                   = data.aws_eks_cluster.default.endpoint
  cluster_ca_certificate = base64decode(data.aws_eks_cluster.default.certificate_authority[0].data)
  token                  = data.aws_eks_cluster_auth.default.token
}
</code></pre>
<p>From HashiCorp <a href="https://github.com/hashicorp/terraform-provider-kubernetes/blob/main/_examples/eks/kubernetes-config/main.tf" rel="nofollow noreferrer">github repo</a></p>
