It seems there is an issue with order of deletion, the aws-auth configmap used for accessing the cluster is getting destroyed before the deletion of other resources, even after that EBS volumes are left behind, need help on that also. Any option to ignore this particular resource during the terraform destroy?
I tried prevent_destroy as below to skip the resource during terraform destroy.
resource "kubernetes_config_map" "aws_auth" {
metadata {
name = "aws-auth"
namespace = "kube-system"
}
data = {
mapRoles = yamlencode(local.map_roles)
mapUsers = yamlencode(local.map_users)
}
lifecycle {
prevent_destroy = true
}
}
But got error as below.
╷
│ Error: Instance cannot be destroyed
│
│ on aws-auth.tf line 20:
│ 20: resource "kubernetes_config_map" "aws_auth" {
│
│ Resource kubernetes_config_map.aws_auth has lifecycle.prevent_destroy set,
│ but the plan calls for this resource to be destroyed. To avoid this error
│ and continue with the plan, either disable lifecycle.prevent_destroy or
│ reduce the scope of the plan using the -target flag.
╵