<p>I'm using 0.14.2 Terraform version. I'm trying to deploy an EKS cluster with two nodes with this code:</p>
<pre><code>resource &quot;aws_eks_cluster&quot; &quot;cluster&quot; {
  enabled_cluster_log_types = []
  name                      = var.cluster_name
  role_arn                  = aws_iam_role.cluster.arn
  version                   = var.eks_version
  vpc_config {
    subnet_ids              = flatten([ aws_subnet.private.*.id, aws_subnet.public.*.id ])
    security_group_ids      = []
    endpoint_private_access = &quot;true&quot;
    endpoint_public_access  = &quot;true&quot;
  }
  tags = var.tags[terraform.workspace]

  depends_on = [
    aws_iam_role_policy_attachment.cluster_AmazonEKSClusterPolicy,
    aws_iam_role_policy_attachment.cluster_AmazonEKSServicePolicy,
    aws_cloudwatch_log_group.cluster
  ]
}

resource &quot;aws_launch_configuration&quot; &quot;eks-managenodes&quot; {
  for_each                    = local.ob
  
  name_prefix                 = &quot;${var.cluster_name}-launch-${each.value}&quot;
  image_id                    = &quot;ami-038341f2c72928ada&quot;
  instance_type               = &quot;t3.medium&quot;
  user_data = &lt;&lt;-EOF
      #!/bin/bash
      set -o xtrace
      /etc/eks/bootstrap.sh ${var.cluster_name}
      EOF

  root_block_device {
    delete_on_termination = true
    volume_size = 30
    volume_type = &quot;gp2&quot;
  }

  lifecycle {
    create_before_destroy = true
  }
}

resource &quot;aws_autoscaling_group&quot; &quot;eks-asg&quot; {
  for_each        = local.ob

  desired_capacity     = 1
  launch_configuration = aws_launch_configuration.eks-managenodes[each.value].id
  max_size             = 1
  min_size             = 1
  name                 = &quot;${var.cluster_name}-node-${each.value}&quot;
  vpc_zone_identifier  = aws_subnet.private.*.id

  tag {
    key                 = &quot;Name&quot;
    value               = &quot;eks-manage-node-${each.value}&quot;
    propagate_at_launch = true
  }

  tag {
    key                 = &quot;kubernetes.io/cluster/${var.cluster_name}&quot;
    value               = &quot;owned&quot;
    propagate_at_launch = true
  }
  depends_on = [
    aws_launch_configuration.eks-managenodes,
    aws_eks_cluster.cluster
  ]
}

</code></pre>
<p>Then, the cluster deploy fine, the ASG and the EC2 instances deploy fine, but the problem is that these instances doesn't attach to the corresponding cluster and I don't find the problem..</p>
<p>Any idea?
Thanks</p>

<p>Nodes can fail to join a cluster for a variety of reasons.</p>
<ol>
<li>a failure during cloud-init may be preventing them from registering with the cluster control plane.</li>
<li>there may be IAM authentication failures.</li>
</ol>
<p>Debugging steps:</p>
<ol>
<li><p>Ssh into a node and check <code>/var/log/cloud-init.log</code> and <code>/var/log/cloud-init-output.log</code> to ensure that it completed without error.</p>
</li>
<li><p>verify that <code>kubelet</code> and <code>aws-node</code> processes are running on the ec2 nodes.  Both should show up in <code>ps</code></p>
</li>
<li><p>check that <code>/etc/eks/bootstrap.sh</code> exists.  Try invoking it as root with the arguments  <code>/etc/eks/bootstrap.sh --apiserver-endpoint '${endpoint}' --b64-cluster-ca '${cluster_ca_data}' '${cluster_name}'</code> using the variables sourced from the EKS overview page in the AWS ui.</p>
</li>
<li><p>check the <code>aws-auth</code> config map in <code>kube-system</code> and verify the ec2 role is mapped like this:</p>
</li>
</ol>
<pre><code>    mapRoles: |
      - rolearn: arn:aws:iam::&lt;account id&gt;:role/&lt;node role&gt;
        username: system:node:{{EC2PrivateDNSName}}
        groups:
          - system:bootstrappers
          - system:nodes
</code></pre>
<p>as without this the node will not be able to authenticate to the cluster.</p>
<p>When in doubt, try the newest version of the EKS ami for your cluster's kubernetes version - some AMIs are broken.</p>
