I have successfully created all the resources, including the EKS cluster. However, when I try to add the certificate.tf
and ingress.tf
files, which involve the kubernetes_manifest
resource,
I encounter the following error: “dial tcp: lookup F0C4662D0EF9C5F6301B98A349A82175.gr7.us-east-2.eks.amazonaws.com: no such host.” It seems Terraform is attempting to connect to the Kubernetes API before the EKS cluster is fully created.
I’ve tried using the depends_on
argument, but it hasn’t resolved the issue. I’ve attached the error for reference.
What would be the solution for this?
Hi @NChittimalla, this is a known issue with initialising managed Kubernetes clusters. The official documentation recommends splitting the two steps (creating the cluster, and managing it) into two separate Terraform configuration with independent apply steps: Terraform Registry
The other option is to use the -target
command line argument to selectively apply the AWS resources first. Then following up with a full plan to create the Kubernetes resources once the cluster definitely exists.
Unfortunately this is a difficult problem with the Kubernetes provider, since we cannot even plan changes to the Kubernetes provider before it exists there isn’t a way within Terraform currently to handle this automatically.
The upcoming Terraform Stacks feature will include capabilities for handling this automatically: Terraform stacks, explained
Thanks!