'how to remove terraform kubernetes resources and kubernetes cluster in single run
I have CI/CD pipeline which runs terraform plan and terraform apply on each commit I do to my repo.
I created something like following:
module "gke" {
source = "registry.terraform.io/terraform-google-modules/kubernetes-engine/google"
...
}
...
module "workload_identity" {
source = "registry.terraform.io/terraform-google-modules/kubernetes-engine/google//modules/workload-identity"
cluster_name = module.gke.name
...
depends_on = [
module.gke.endpoint
]
}
...
provider "kubernetes" {
host = "https://${module.gke.endpoint}"
...
}
...
resource "kubernetes_ingress_v1" "main" {
metadata {
...
}
...
depends_on = [
module.gke.endpoint
]
}
If I'll remove all this code in single commit it will fail on plan stage because of multiple reasons:
kubernetes_ingress_v1.mainwill not be able to access cluster to delete itmodule.workload_identitywill also not be able to access cluster because it has some kubernetes resources inside.
I can do it in multiple commits, but I wonder if there is a way to fix a code to make plan work?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
