'CloudFormation - Attached VPC Lambda stuck in DELETE_IN_PROGRESS - can't delete ENI
I have a Lambda attached to a VPC in a CF stack and when I try to delete the stack the lambda will get stuck in DELETE_IN_PROGRESS for hours.
If I try to manually delete the ENI it won't let me, with an error message eni is use by another service.
If I run the AWS script to detect what is using the ENI, I get a response that the ENI is not being used by any service. I can confirm that the lambda was deleted by going to the Lambda UI.
The only solution is to wait for a couple of hours until the ENI is deleted. This is very bad for us as we create a CF stack for our e2e tests before a new release and we can't wait for hours until is deleted.
Any workaround for this problem? The lambda role is only deleted after the Lambda is deleted.
Solution 1:[1]
I am facing the same problem with yours during my deployment with CloudFormation as well. And the provided helper script was not helpful in my case as well.
I believe that there is no way that we can disturb AWS managed ENIs which are created for your Lambda function. Maybe, I think they manage the deletion process over some signals sending to SQS queues or RabbitMQ.
Here is how I manage this:
- Firstly, I manage this by manually removing any VPC configuration from my Lambda functions.
- Then, I move forward with CloudFormation deletion or replacement.
This can solve waiting issues but will need to write some bash script to remove VPC configuration from those functions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Binh Nguyen |
