Remove a resource from the Terraform state

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: ...

July 7, 2025 · 1 min · 161 words · Maurizio Branca