<p>I'm trying to deploy an AWS environment using terraform. The EC2 instances and the cluster is created fine, but it fails when trying to join the instances with the cluster.</p>
<pre><code>Error: error waiting for EKS Node Group (env-dev:node_1) to create: unexpected state 'CREATE_FAILED', wanted target 'ACTIVE'. last error: 1 error occurred:
* i-022a2d319d457ab83, i-0374c9efbb32b1f0f, i-05b42da747ca0c8cd, i-08439b352ff4bcc5f, i-0d286addbf2eedd2a, i-0dc6f1bd12b372427, i-0ed373f52f9e27510: NodeCreationFailure: Instances failed to join the kubernetes cluster
</code></pre>
<p>According to CloudWatch, this is where it fails</p>
<pre><code>&quot;responseObject&quot;: {
    &quot;kind&quot;: &quot;Status&quot;,
    &quot;apiVersion&quot;: &quot;v1&quot;,
    &quot;metadata&quot;: {},
    &quot;status&quot;: &quot;Failure&quot;,
    &quot;message&quot;: &quot;Node \&quot;ip-10-206-68-167.eu-west-1.compute.internal\&quot; is invalid: metadata.labels: Invalid value: \&quot;ip-10-206-68-167.xxxx-xxxxxxxxxxxxxxxxxxxxx-xxxx-xxx.eu-west-1.a\&quot;: must be no more than 63 characters&quot;,
    &quot;reason&quot;: &quot;Invalid&quot;,
    &quot;details&quot;: {
        &quot;name&quot;: &quot;ip-10-206-68-167.eu-west-1.compute.internal&quot;,
        &quot;kind&quot;: &quot;Node&quot;,
        &quot;causes&quot;: [
            {
                &quot;reason&quot;: &quot;FieldValueInvalid&quot;,
                &quot;message&quot;: &quot;Invalid value: \&quot;ip-10-206-68-167.xxxx-xxxxxxxxxxxxxxxxxxxxx-xxxx-xxx.eu-west-1.a\&quot;: must be no more than 63 characters&quot;,
                &quot;field&quot;: &quot;metadata.labels&quot;
            }
        ]
    },
    &quot;code&quot;: 422
}
</code></pre>
<p>Is there any way to override the hostname using terraform?</p>
<p>EDIT:</p>
<p>Snippet of the terraform:</p>
<pre><code>variable &quot;db_subnet_ids&quot; { default = [&quot;subnet-04f6e659f2b2851f2&quot;, &quot;subnet-0a42b2ec54b5aa143&quot;] }

resource &quot;aws_eks_cluster&quot; &quot;cluster&quot; {
 enabled_cluster_log_types = [
  &quot;api&quot;,
  &quot;audit&quot;,
  &quot;authenticator&quot;,
  &quot;controllerManager&quot;,
  &quot;scheduler&quot;,
 ]
 name = &quot;env-${var.suffix}&quot;
 role_arn = aws_iam_role.eks_cluster_role.arn
 vpc_config {
  subnet_ids = var.db_subnet_ids
  security_group_ids = [aws_security_group.cluster_http.id, aws_security_group.cluster_https.id]
 }
  
 depends_on = [
  aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy,
  aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy,
  aws_iam_role_policy_attachment.AmazonEC2ContainerRegistryReadOnly,
 ]
}

resource &quot;aws_eks_node_group&quot; &quot;cluster&quot; {
 cluster_name = aws_eks_cluster.cluster.name
 node_group_name = &quot;node_1&quot;
 node_role_arn = aws_iam_role.eks_nodes_role.arn
 subnet_ids = var.db_subnet_ids
 scaling_config {
  desired_size = 7
  max_size = 7
  min_size = 7
 }
 ami_type = &quot;AL2_x86_64&quot;
 capacity_type = &quot;ON_DEMAND&quot;
 disk_size = 50
 instance_types = [&quot;t3.large&quot;]

 depends_on = [
  aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy,
  aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy,
  aws_iam_role_policy_attachment.AmazonEC2ContainerRegistryReadOnly,
 ]
}
</code></pre>
<p>The VPC is created manually, so the configuration is as so:</p>
<p>Subnet ID: subnet-04f6e659f2b2851f2<br />
Name: xxxx-xxxxxxxxxxxxxxxxxxxxx-xxxx-xxx-private-eu-west-1a<br />
IPv4 CIDR: 10.206.68.160/28</p>
<p>Subnet ID: subnet-0a42b2ec54b5aa143<br />
Name: xxxx-xxxxxxxxxxxxxxxxxxxxx-xxxx-xxx-private-eu-west-1b<br />
IPv4 CIDR: 10.206.68.176/28</p>
<p>And the VPC<br />
Name: xxxx-xxxxxxxxxxxxxxxxxxxxx-xxxx-xxx<br />
VIP ID: vpc-09a3e88350a018cbf<br />
IPv4 CIDR: 10.206.68.160/27
DHCP options set ID: dopt-0ea3823bed3d5ff2c</p>
<p>DHCP options set<br />
ID: dopt-0ea3823bed3d5ff2c<br />
Name: xxxx-xxxxxxxxxxxxxxxxxxxxx-xxxx-xxxx</p>
<p>Name later altered to: xxxx-xx-xxxx-xxxx (2nd word shortened)
Explanation in my answer below.</p>

Mejenborg
<p>The issue is somewhat resolved. Not sure I'm a big fan of the solution, but it works.</p>
<p>So the node hostnames was created by appending</p>
<ul>
<li>IP address</li>
<li>DHCP options set name of from the VPC</li>
<li>Not exactly sure where &quot;eu-west-1&quot; and &quot;a&quot; derives from.<br />
Region of the VPC perhaps? And the &quot;a&quot; from the subnet?</li>
</ul>
<p>which it ended up with something like:</p>
<blockquote>
<p>ip-10-206-68-167.xxxx-xxxxxxxxxxxxxxxxxxxxx-xxxx-xxx.eu-west-1.a</p>
</blockquote>
<p>So by shortening the DHCP options set name, the hostnames was therefore shortened as well, and everything is working just fine.</p>
