kostaleonard / populare-iac

Populare infrastructure as code.
MIT License
2 stars 0 forks source link

terraform destroy does not clean up all resources correctly #14

Closed kostaleonard closed 2 years ago

kostaleonard commented 2 years ago

The last time that I ran terraform destroy, it failed after 20 minutes. It had cleaned up most resources, perhaps everything except the load balancer that was provisioned as part of the Kubernetes manifest and the VPC subnets. The VPC subnets couldn't be deleted because some resource (presumably the load balancer) was dependent on it. I think we can make terraform destroy work correctly by performing either of the following:

  1. Delete everything in the Kubernetes cluster, then run terraform destroy, although I don't know if this would completely work.
  2. Have a separate plan for the Kubernetes configuration and EKS cluster; the Kubernetes plan can reference a load balancer, which may then get correctly destroyed.

For the time being, the workaround is to run terraform destroy and then clean up resources in AWS console.

kostaleonard commented 2 years ago

In this terraform guide, the developers put the EKS and Kubernetes terraform plans in separate directories, applying first the EKS plan and then the Kubernetes plan. To clean up, delete the Kubernetes resources first, then the EKS resources.