'Cannot delete AWS Lambda@Edge replicas
This question already exists here but I think it will have more impact on SO.
I created an AWS Lambda@Edge function in order to rewrite Cloudfront URLs before they reach the Origin.
AWS Lambda@Edge Function are automatically replicated through all regions when published, so I was not surprised to see this in every region:
Here began the problems:
I deleted the Lambda@Edge because it was a test and I wanted to start a fresh new one, but the replicas weren't deleted at the same time.
It was no big deal at the time, I thought that I simply could create a new Lambda@Edge function.
But you can't because the Cloudfront trigger can only be used one function at a time (as the replicas use it, you cannot create a new one).
Moreover, the trigger cannot be deleted either.
So now I'm stuck with Lambda@Edge replicas everywhere that I cannot delete and I cannot create similar ones.
TL;DR
- I created a Lambda@Edge with a CloudFront trigger
- I deleted it to create a new (similar) one
- Now there is a replica still existing
- I can't delete the replica
- I can't create a new Lambda@Edge because the trigger is already "in use" by the replica (that I can't delete)
I'd be grateful to get some help on this
François
EDIT:
I definitely think it's a bug because in my replica's page, the link to the Master ARN responds with a 404.
Solution 1:[1]
I found part of an answer:
It turns out that I needed to delete the trigger in the behavior of Cloudfront.
Simply:
- Go to your Cloudfront distribution's behaviors
- Check the one triggering the LambdaEdge
- Click
Edit
- Go at the very bottom of the page and click the X to delete the trigger
Still, I can't delete the replicas but at least I can create new lambdas for this trigger...
Solution 2:[2]
There is now a documentation here stating that replicas are deleted after a "few hours" - which would imply that I then can also delete the Lambda function.
Update 2020-01-05: If you delete the Lambdas it takes ~1 h and everything is gone! So it is just slower but behave similar to normal Lambdas?
Solution 3:[3]
I asked this problem to AWS support and its answer was like: "you cannot delete replicated lambda functions for now, but we understand many people requires this".
AWS Lambda@Edge http://docs.aws.amazon.com/es_es/lambda/latest/dg/lambda-edge.html
When you create a trigger, Lambda replicates the function to AWS Regions and CloudFront edge locations around the globe. Note that replicas can't be edited or deleted.
Solution 4:[4]
Hi francois, yves, reki I have figured out the solution to delete Lambda@edge replica.
- Firstly, Login to CloudFront Console and go to your Distribution.
- Under the Behaviors Tab - tick the listed Behavior and edit
- Scroll down to Lambda Function Associations and remove any Association by clicking the X.
- Press yes,edit to save the changes. --- Now that you have removed the Associations it's time to delete the Lambda@edge replicas
- Go to Lambda Console and open your lambda( you wish to delete).
- On the top menus - Qualifiers -> Versions-> choose the listed drop-down version
- It will open that @edgeLambda Version
- On the top menus - Actions -> Delete version
- This way , deleting all the versions - you are left with $LATEST
- Deleting that also - you are finally able to delete the Lambda@edge Function
Note!> Please remember to delete any IAM Roles and Permissions associated with Lambda@edge Functions.
I hope this will works for you, Enjoy :)
Solution 5:[5]
Even I tried * To delete trigger then create lambda (in my case lambda reaches nearly 30)*,but i couldnt create new lambda@edge. Finally i did this
Removed the cloud-front distribution which is associated with lambda function, now its simple to move further. Please assure that distribution only used by that related lambda.
Solution 6:[6]
Best answer I have found to be able to delete the function, follow the steps below:
- For every version of the deployed function, delete the triggers of that specific function.
- Wait several hours until AWS will automatically delete all deployed replicas of that specific function.
- Once all replicas are automatically deleted, try again to delete the Lambda function. You should succeed.
Source: https://adrian.simionov.io/aws/2019/08/28/deleting-lambda-at-edge-functions.html
Solution 7:[7]
With the old AWS console
Until this date, the documentation mentions the old solution mentioned also by the OP:
With the new AWS console
In the new interface of the console, go to:
CloudFront > Distributions > **DistribName** > Edit behavior
Then you can just change the Function type to No association and then Save changes, that's all.
Solution 8:[8]
I had a similar issue where my Lambda@Edge did not have any Cloudfront triggers at all; however, I still wasn't able to delete it. I tried the following and it 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.
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 | Francois |
Solution 2 | |
Solution 3 | reki |
Solution 4 | |
Solution 5 | selvasundarraj |
Solution 6 | |
Solution 7 | |
Solution 8 | Ali Ameer |