<p>After deleting kubernetes cluster with &quot;terraform destroy&quot; I can't create it again anymore.</p>
<p>&quot;terraform apply&quot; returns the following error message:</p>
<blockquote>
<p>Error: Kubernetes cluster unreachable: invalid configuration: no
configuration has been provided, try setting KUBERNETES_MASTER
environment variable</p>
</blockquote>
<p>Here is the terraform configuration:</p>
<pre><code>terraform {
  backend &quot;s3&quot; {
    bucket = &quot;skyglass-msur&quot;
    key    = &quot;terraform/backend&quot;
    region = &quot;us-east-1&quot;
  }
}

locals {
  env_name         = &quot;staging&quot;
  aws_region       = &quot;us-east-1&quot;
  k8s_cluster_name = &quot;ms-cluster&quot;
}

variable &quot;mysql_password&quot; {
  type        = string
  description = &quot;Expected to be retrieved from environment variable TF_VAR_mysql_password&quot;
}

provider &quot;aws&quot; {
  region = local.aws_region
}

data &quot;aws_eks_cluster&quot; &quot;msur&quot; {
  name = module.aws-kubernetes-cluster.eks_cluster_id
}

module &quot;aws-network&quot; {
  source = &quot;github.com/skyglass-microservices/module-aws-network&quot;

  env_name              = local.env_name
  vpc_name              = &quot;msur-VPC&quot;
  cluster_name          = local.k8s_cluster_name
  aws_region            = local.aws_region
  main_vpc_cidr         = &quot;10.10.0.0/16&quot;
  public_subnet_a_cidr  = &quot;10.10.0.0/18&quot;
  public_subnet_b_cidr  = &quot;10.10.64.0/18&quot;
  private_subnet_a_cidr = &quot;10.10.128.0/18&quot;
  private_subnet_b_cidr = &quot;10.10.192.0/18&quot;
}

module &quot;aws-kubernetes-cluster&quot; {
  source = &quot;github.com/skyglass-microservices/module-aws-kubernetes&quot;

  ms_namespace       = &quot;microservices&quot;
  env_name           = local.env_name
  aws_region         = local.aws_region
  cluster_name       = local.k8s_cluster_name
  vpc_id             = module.aws-network.vpc_id
  cluster_subnet_ids = module.aws-network.subnet_ids

  nodegroup_subnet_ids     = module.aws-network.private_subnet_ids
  nodegroup_disk_size      = &quot;20&quot;
  nodegroup_instance_types = [&quot;t3.medium&quot;]
  nodegroup_desired_size   = 1
  nodegroup_min_size       = 1
  nodegroup_max_size       = 5
}

# Create namespace
# Use kubernetes provider to work with the kubernetes cluster API
provider &quot;kubernetes&quot; {
  # load_config_file       = false
  cluster_ca_certificate = base64decode(data.aws_eks_cluster.msur.certificate_authority.0.data)
  host                   = data.aws_eks_cluster.msur.endpoint
  exec {
    api_version = &quot;client.authentication.k8s.io/v1alpha1&quot;
    command     = &quot;aws-iam-authenticator&quot;
    args        = [&quot;token&quot;, &quot;-i&quot;, &quot;${data.aws_eks_cluster.msur.name}&quot;]
  }
}

# Create a namespace for microservice pods
resource &quot;kubernetes_namespace&quot; &quot;ms-namespace&quot; {
  metadata {
    name = &quot;microservices&quot;
  }
}
</code></pre>
<p>P.S. There seems to be the issue with terraform kubernetes provider for 0.14.7</p>
<p>I couldn't use &quot;load_config_file&quot; = false in this version, so I had to comment it, which seems to be the reason of this issue.</p>
<p>P.P.S. It could also be the issue with outdated cluster_ca_certificate, which terraform tries to use: deleting this certificate could be enough, although I'm not sure, where it is stored.</p>

Mykhailo Skliar
<p>Before doing something radical like manipulating the state directly, try setting the KUBE_CONFIG_PATH variable:</p>
<pre><code>export KUBE_CONFIG_PATH=/path/to/.kube/config
</code></pre>
<p>After this rerun the <code>plan</code> or <code>apply</code> command.
This has fixed the issue for me.</p>
