CloudFormation is buggy and won't properly clean up VPC and Internet Gateway

0

I'm using the eksctl utility to build and destroy Kubernetes clusters on Amazon EKS. When I delete the CloudFormation stacks, most of the resources are properly destroyed, including the EKS cluster itself. However, the VPC and Internet Gateway are getting hung up, and will not clean up properly. This is leaving my account with a bunch of orphaned VPC resources that I don't want, and contributing to my resource limits unnecessarily. The CloudFormation stacks get stuck in the DELETE_FAILED state.

The vpc 'vpc-096bd7c39859b6afb' has dependencies and cannot be deleted. (Service: AmazonEC2; Status Code: 400; Error Code: DependencyViolation; Request ID: 28dda82e-9aa9-4d05-b870-9371d77cee23; Proxy: null)
The internetGateway 'igw-0c214b63b8b795b81' has dependencies and cannot be deleted. (Service: Ec2, Status Code: 400, Request ID: 71c41fe9-1247-4a29-ac47-d5c32d29837d, Extended Request ID: null)

Question: Can the AWS CloudFormation team fix this, so that the resources are properly cleaned up?

1 回答
2
已接受的回答

As noted here, do you have any active services associated with LBs in your EKS cluster?

If so, you should delete those services through kubectl and wait until the LBs are deleted properly.

Also generally it is recommended you use eksctl, or ensure you followed the steps in the above page when deleting clusters.

As a last resort, you can try to delete the IGWs and resources, such as ELBs, within the VPC manually to resolve dependencies and clean up resources.

Jason_S
已回答 2 年前
  • Yes that is the case. Thanks for pointing that out. I actually discovered that by attempting to manually delete one of the VPCs, and noticed there were ENIs attached to it. However, the CloudFormation service could do a much better job of describing why the stack fails to delete.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则