rebuy-de / aws-nuke

Nuke a whole AWS account and delete all its resources.
MIT License
5.52k stars 709 forks source link

Fails to delete EKS cluster because it does not try to delete the EKS nodegroup first #573

Open ecerulm opened 3 years ago

ecerulm commented 3 years ago

aws-nuke fails to delete the eks cluster, It seems that it does not even attempt to delete the EKS nodegroup (which i think it's a prerequisite to be able to delete the EKS cluster)

Removal requested: 0 waiting, 13 failed, 78 skipped, 86 finished
eu-north-1 - EC2SecurityGroup - sg-059bcffdfe04ee34f - ERRO[0331] DependencyViolation: resource sg-059bcffdfe04ee34f has a dependent object
    status code: 400, request id: 61bd8dc7-2b92-484e-ab64-9ccde72e01fd
[Name: "clustername-441991687"] - failed
ERRO[0331] DependencyViolation: resource sg-06c760a39a7f09f95 has a dependent object
    status code: 400, request id: 6e08d6c1-1092-4636-a311-71b800730895
eu-north-1 - EC2SecurityGroup - sg-06c760a39a7f09f95 - [Name: "bia-b2b-eks-dev20201103131536709900000004"] - failed
ERRO[0331] ResourceInUseException: Cluster has nodegroups attached
    status code: 409, request id: 114ce106-ab03-439f-bf3c-74a26607e4ea
eu-north-1 - EKSCluster - clustername - failed

If I delete the nodegroup manually from the AWS console and retry with aws-nuke then it succeeds in deleting the eks cluster.

spkane commented 3 years ago

It is indeed a requirement that any attached nodegroups must be deleted before the EKS cluster is deleted. With the AWS CLI you need to do something like this to achieve the same results.

aws eks list-nodegroups --cluster-name app-opal-weapon
aws eks delete-nodegroup --cluster-name app-opal-weapon --nodegroup-name app-opal-weapon-default-winning-chipmunk
aws eks delete-cluster --name app-opal-weapon

Just trying to delete the cluster without deleting the nodegroups first will result in an error.

akshitkh commented 3 years ago

605 can fix this.