删除顺序似乎存在问题,用于访问集群的 aws-auth configmap 在删除其他资源之前就被销毁了,甚至在 EBS 卷被留下之后也是如此,对此也需要帮助。在 terraform 销毁期间,有没有忽略此特定资源的选项?
我尝试使用如下的prevent_destroy来跳过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
}
}
但出现如下错误。
╷
│ 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.
╵