Terraform: dial tcp [::1]:80: connect: connection refused

╷
│ Error: Post "http://localhost/api/v1/namespaces/kube-system/configmaps": dial tcp [::1]:80: connect: connection refused
│ 
│   with module.eks.kubernetes_config_map.aws_auth[0],
│   on .terraform/modules/eks/aws_auth.tf line 63, in resource "kubernetes_config_map" "aws_auth":
│   63: resource "kubernetes_config_map" "aws_auth" {

It means that kube config not found by default path.

It can be set by the following command

export KUBECONFIG=~/.kube/custom-config.conf

Another way to check provider section. parameter config_path

provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
token = data.aws_eks_cluster_auth.cluster.token
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
config_context = data.aws_eks_cluster.cluster.arn
config_path = var.eks_kube_config_path
}

eventually, i would remove state aws_auth and disable terraform for managing that map:

terraform state rm 'module.eks.kubernetes_config_map.aws_auth'

module "eks" {
  manage_aws_auth = false
}

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Design a site like this with WordPress.com
Get started