I have a CloudFormation stack with Lambda function inside a VPC,
When trying to delete the stack, the AWS CloudFormation gets stuck for 25-30 at least,
I get the following message in the events -
CloudFormation is waiting for NetworkInterfaces associated with the Lambda Function to be cleaned up.
It seems to be due to ENIs being attached to the Functions and the SecurityGroups.
From the Console it did not allow me to delete either the ENI forcibly nor the Security Group, to which the ENI is attached,
So do I just have to wait?
I found some questions and blogs which are even 2 years old,
No solution from AWS?
Automations are supposed to be quick, this is proving to be a huge blocker.
Reference -
CloudFormation issue: couldn't delete stack
https://forum.serverless.com/t/very-long-delay-when-doing-sls-remove-of-lambda-in-a-vpc/2535
AWS CloudFormation uses elastic network interfaces, and elastic network interfaces can only be deleted by Lambda. Deleting an elastic network interface can take up to 45 minutes.
All in all, CloudFormation makes deploying AWS Lambda functions incredibly simple. Start by creating the template file that will define your resources. This will be your working folder for your code. Next, create your function in the appropriate file for your desired Lambda runtime.
As you and others have already mentioned, this is a known issue/"feature". When I last spoke about this with someone from AWS, there were no plans of changing this behavior. If time is really of the essence for you, one work-around you can try is this:
Update the Lambda resources in CloudFormation with DeletionPolicy
set to Retain
.
Manually (or via script/API) delete the Lambda and associated resources like ENIs
However, I would not recommend against the above mentioned work-around. It is easy to forget something which will leave you with a cluttered environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With