I'm currently working on an fully managed by Terraform environment but I reached some limitations and I would like to know if there is a feature or a workaround to do what I want :
I have an environment described like that :
- A VPC with public and private subnets
- An EKS cluster with some workers
- Some kubernetes configurations (using the kubernetes provider)
- Some helm configurations (using the helm provider)
Everything work, but when I want to do a full clean up by running terraform destroy
I have to destroy some resources one by one with -target
option and then delete manually some references in the state file.
Two reasons why I would like to do that:
Just because it fails
Don't know why, but I was unable to destroy with Terraform and manually some subnets (imposible to detach the internet gateway) but I was able to destroy them by simply destroying the VPC.
In this case, I would like to tell to Terraform to only delete the VPC, by doing that, AWS automatically destroy related components such as Subnets, Internet Gateway, Route table, Networks ACL, etc.
Because it would be faster
I'm using Terraform with Kubernetes (and Helm) provider to define my Kubernetes configuration, but when I run
terraform destroy
it will delete all the Kubernetes resources, then the Cluster (and workers).Only deleting the Cluster would be really faster.
So here is my question : Is it possible to exclude resources to the destroy process in the Terraform configuration files ?