Deleting Lambda@Edge functions

If you ever tried to delete a Lambda@Edge function, you probably noticed that if the function would have been previously deployed to AWS edge locations, you would encounter an error and would not be able to delete it. Which is pretty frustrating, right?

You would get an error similar to:

Error - Deleting Lambda Edge

An error occurred when deleting this version: Lambda was unable to delete arn:aws:lambda:us-east-1:__ACCOUNT__>:function:__FUNCTION_NAME__:1 because it is a replicated function. Please see our documentation for Deleting Lambda@Edge Functions and Replicas.

To de able to delete the function, follow the steps below:

  1. For every version of the deployed function, delete the triggers of that specific function.
  2. Wait several hours until AWS will automatically delete all deployed replicas of that specific function.
  3. Once all replicas are automatically deleted, try again to delete the Lambda function. You should succeed.

This feature became publically available in March 2018. Before, it was completly impossible to get rid of Lambda@Edge functions, even after the Cloudfront triggers would have been removed.

Clean-up your AWS account

If you did have such issues in the past, now it is a good time to start cleaning up your AWS account of all the unused functions which might still be there.

I hope you found this post informative.