Skip to main content
Knowledge Base

Cannot connect to endpoint to refresh aws-auth ConfigMap

Answer

Hello, I recently started seeing this error message. I checked my kubectl commands (setup with kubergrunt eks) and I can reach the cluster without issue. My config map looks ok. Where is it getting the `http://localhost` host setting from? I am using version `v0.84.3`, and for what it's worth this issue cropped up out of the blue while troubleshooting something else. Thanks! ``` module.eks_k8s_role_mapping.kubernetes_config_map.eks_to_k8s_role_mapping: Refreshing state... [id=kube-system/aws-auth] ╷ │ Error: Get "http://localhost/api/v1/namespaces/kube-system/configmaps/aws-auth": dial tcp [::1]:80: connect: connection refused │ │ with module.eks_k8s_role_mapping.kubernetes_config_map.eks_to_k8s_role_mapping, │ on .terraform/modules/eks_k8s_role_mapping/modules/eks-k8s-role-mapping/main.tf line 33, in resource "kubernetes_config_map" "eks_to_k8s_role_mapping": │ 33: resource "kubernetes_config_map" "eks_to_k8s_role_mapping" { │ ╵ Releasing state lock. This may take a few moments... ERRO[0116] 1 error occurred: * exit status 1 ```

This is most likely due to missing / invalid `kubernetes` provider configuration. If you add one - either via `generate` block, `include` or explicit provider configuration, the `kubernetes` provider has correct configuration for API endpoints and auth. Without explicit provider configuration, Terraform defaults to localhost and that's why you're seeing the `http://localhost/api/v1/...` in the output. The provider generator template can be found here: https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/master/examples/for-production/infrastructure-live/provider_k8s_helm_for_eks.template.hcl