Resource "kubernetes_service_account" cannot be made depend_on resource "aws_eks_cluster" cannot


I’m trying to create EKS Cluster using terraform and also wanted to create few services after the creation of the cluster. But when i tried to add depends_on it doesn’t work.

resource "aws_eks_cluster" "eks" {
  name = "${var.clustername}"
  version = "${var.kubeversion}"
  role_arn = aws_iam_role.eks-iam-role.arn
  enabled_cluster_log_types = ["api", "authenticator", "audit", "scheduler", "controllerManager"]
  vpc_config {
    endpoint_private_access = true
    endpoint_public_access  = false
    subnet_ids = [var.subnet_id_1, var.subnet_id_2]
  kubernetes_network_config {
  	ip_family         = "ipv4"

  depends_on = [

I also wanted to create a namespace after the cluster has been created so i added below code which is failing with an error even after adding depends_on

#Creating namespace as test
resource "kubernetes_namespace" "test" {
  metadata {
    annotations = {
      name = "test-annotation"

    labels = {
      mylabel = "test-label"

    name = "test"
  depends_on = [


Error: Get "http://localhost/api/v1/namespaces/test": dial tcp connect: connection refused

I’ve added the authentication info in kubernetes provider but however the namespace creation should be skipped before the cluster has been created.

Any thoughts