Sometimes you’re working on a codebase new to you and terraform destroy
fails with a weird error like:
1
2
3
4
5
6
7
8
| ╷
│ Error: Get "http://localhost/api/v1/namespaces/kube-public/configmaps/local-registry-hosting": dial tcp [::1]:80: connect: connection refused
│
│ with kubernetes_config_map.registry,
│ on main.tf line 97, in resource "kubernetes_config_map" "registry":
│ 97: resource "kubernetes_config_map" "registry" {
│
╵
|
This is probably an edge case in the kubernetes_config_map
combined with EKS.
You should fix the root cause, but if it’s late and all you want is tear down the test EKS cluster, you can remove the offending configmap from the state:
1
2
3
4
| # search for the offending resource in the state
$ terraform state list | grep config
kubernetes_config_map.registry
module.eks.terraform_data.kubeconfig
|
Remove the configmap from the state:
1
2
3
| $ terraform state rm kubernetes_config_map.registry
Removed kubernetes_config_map.registry
Successfully removed 1 resource instance(s).
|
And continue destroying the EKS cluster, and start troubleshooting the root cause tomorrow morning with a fresh mind.