romuloleidemer
romuloleidemer

Reputation: 31

Cannot delete Lambda@Edge created by Cloud Formation

I cannot delete a Lambda@Edge function create by Cloud Formation. During the Cloud Formation creation process an error occurred and the rollback process was executed. At the end we can't remove the Lambda created, we resolved the CF problem, renamed the resource and CF created a new Lambda. But the old one continues there. There aren't Cloud Front or another resource linked at the old Lambda and still we can't remove. When we try to remove we receive this message:

An error occurred when deleting your function: Lambda was unable to delete arn:aws:lambda:us-east-1:326353638202:function:web-comp-cloud-front-fn-prod:2 because it is a replicated function. Please see our documentation for Deleting Lambda@Edge Functions and Replicas.

I know that if there aren't linked resources to Lambda@Edge after some minutes the replicas are deleted. But we can't find the linked resources.

Thank you in advance for your help.

Upvotes: 3

Views: 2122

Answers (2)

Ali Ameer
Ali Ameer

Reputation: 49

I had a similar issue where I simply wasn't able to delete a Lambda@Edge, and the following helped,

  • Create a new Cloudfront distribution, and associate your Lambda@Edge with this new distribution.
  • Wait for the distribution to be fully deployed.
  • Remove the association of your Lambda@Edge from the Cloudfront distribution that you just created.
  • Wait for the distribution to be fully deployed.
  • Additionally, wait for a few more minutes.
  • Then, try to delete your Lambda@Edge.

Upvotes: 1

stijndepestel
stijndepestel

Reputation: 3544

The error message clearly indicates that the function still is replicated at the edge, which is the reason why you cannot delete it. So you first have to remove the lamda@edge association before deleting the function. If they are created in the same stack the easiest way is probably to set the lambda function's DeletionPolicy to Retain and to remove it manually afterwards.

Keep in mind that it can take up to a few hours before the replicas are deleted, not after some minutes. Usually, I just wait until the next day to remove them.

Upvotes: 1

Related Questions