<p>I would like to deploy a minimal k8s cluster on AWS with Terraform and install a Nginx Ingress Controller with Helm.</p>
<p>The terraform code:</p>
<pre><code>provider &quot;aws&quot; {
  region = &quot;us-east-1&quot;
}

data &quot;aws_eks_cluster&quot; &quot;cluster&quot; {
  name = module.eks.cluster_id
}

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

variable &quot;cluster_name&quot; {
  default = &quot;my-cluster&quot;
}

variable &quot;instance_type&quot; {
  default = &quot;t2.large&quot;
}

provider &quot;kubernetes&quot; {
  host                   = data.aws_eks_cluster.cluster.endpoint
  cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
  token                  = data.aws_eks_cluster_auth.cluster.token
  load_config_file       = false
  version                = &quot;~&gt; 1.11&quot;
}

data &quot;aws_availability_zones&quot; &quot;available&quot; {
}


module &quot;vpc&quot; {
  source  = &quot;terraform-aws-modules/vpc/aws&quot;
  version = &quot;3.0.0&quot;

  name                 = &quot;k8s-${var.cluster_name}-vpc&quot;
  cidr                 = &quot;172.16.0.0/16&quot;
  azs                  = data.aws_availability_zones.available.names
  private_subnets      = [&quot;172.16.1.0/24&quot;, &quot;172.16.2.0/24&quot;, &quot;172.16.3.0/24&quot;]
  public_subnets       = [&quot;172.16.4.0/24&quot;, &quot;172.16.5.0/24&quot;, &quot;172.16.6.0/24&quot;]
  enable_nat_gateway   = true
  single_nat_gateway   = true
  enable_dns_hostnames = true

  public_subnet_tags = {
    &quot;kubernetes.io/cluster/${var.cluster_name}&quot; = &quot;shared&quot;
    &quot;kubernetes.io/role/elb&quot;                    = &quot;1&quot;
  }

  private_subnet_tags = {
    &quot;kubernetes.io/cluster/${var.cluster_name}&quot; = &quot;shared&quot;
    &quot;kubernetes.io/role/internal-elb&quot;           = &quot;1&quot;
  }
}

module &quot;eks&quot; {
  source  = &quot;terraform-aws-modules/eks/aws&quot;
  version = &quot;12.2.0&quot;

  cluster_name    = &quot;eks-${var.cluster_name}&quot;
  cluster_version = &quot;1.18&quot;
  subnets         = module.vpc.private_subnets

  vpc_id = module.vpc.vpc_id

  worker_groups = [
   {
     name                          = &quot;worker-group-1&quot;
     instance_type                 = &quot;t3.small&quot;
     additional_userdata           = &quot;echo foo bar&quot;
     asg_desired_capacity          = 2
   },
   {
     name                          = &quot;worker-group-2&quot;
     instance_type                 = &quot;t3.small&quot;
     additional_userdata           = &quot;echo foo bar&quot;
     asg_desired_capacity          = 1
   },
  ]
  

  write_kubeconfig   = true
  config_output_path = &quot;./&quot;

  workers_additional_policies = [aws_iam_policy.worker_policy.arn]
}

resource &quot;aws_iam_policy&quot; &quot;worker_policy&quot; {
  name        = &quot;worker-policy-${var.cluster_name}&quot;
  description = &quot;Worker policy for the ALB Ingress&quot;

  policy = file(&quot;iam-policy.json&quot;)
}
</code></pre>
<p>The installation performs correctly:
<code>helm install my-release nginx-stable/nginx-ingress</code></p>
<pre><code>NAME: my-release
LAST DEPLOYED: Sat Jun 26 22:17:28 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The NGINX Ingress Controller has been installed.
</code></pre>
<p>The <code>kubectl describe service my-release-nginx-ingress</code> returns:</p>
<pre><code>Error syncing load balancer: failed to ensure load balancer: could not find any suitable subnets for creating the ELB
</code></pre>
<p>The VPC is created and the public subnet seems to be correctly tagged, what is lacking to make the Ingress aware of the public subnet ?</p>

val
<p>In the <code>eks</code> modules you are prefixing the cluster name with <code>eks-</code>:</p>
<pre><code>cluster_name    = &quot;eks-${var.cluster_name}&quot;
</code></pre>
<p>However you do not use the prefix in your subnet tags:</p>
<pre><code>&quot;kubernetes.io/cluster/${var.cluster_name}&quot; = &quot;shared&quot;
</code></pre>
<p>Drop the prefix from <code>cluster_name</code> and add it to the cluster name variable (assuming you want the prefix at all). Alternatively, you could add the prefix to your tags to fix the issue, but that approach makes it easier to introduce inconsistencies.</p>
