10

I'm trying to delete an AWS Lambda function through the GUI, but am getting a response: There was an error deleting your function: Lambda was unable to delete arn:aws:lambda:us-east-1:624929674184:function:lambda-auth:1 because it is a replicated function.

enter image description here

How can one delete replicated Lambda functions?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
duhaime
  • 25,611
  • 17
  • 169
  • 224

4 Answers4

13

I have figured out the solution to delete Lambda@edge replica.

  1. Firstly, Login to CloudFront Console and go to your Distribution.
  2. Under the Behaviors Tab - tick the listed Behavior and edit
  3. Scroll down to Lambda Function Associations and remove any Association by clicking the X.
  4. Press yes,edit to save the changes. --- Now that you have removed the Associations it's time to delete the Lambda@edge replicas
  5. Go to Lambda Console and open your lambda( you wish to delete).
  6. On the top menus - Qualifiers -> Versions-> choose the listed drop-down version enter image description here
  7. It will open that @edgeLambda Version
  8. On the top menus - Actions -> Delete version enter image description here
  9. This way , deleting all the versions - you are left with $LATEST
  10. 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 work :)

Please refer the link Delete Lambda@Edge Functions and Replicas, you will find it much useful.

Putnik
  • 5,925
  • 7
  • 38
  • 58
DHEERAJ
  • 571
  • 6
  • 9
  • Did you have to wait couple of hours before deleting the versions? I followed your steps but still cannot delete the version (it has been less than 30 minutes since I removed the trigger from cloudfront). – ccot Jun 03 '20 at 16:52
  • 4
    Follow up; for anyone in this scenario, I had to wait 1 hour before I was able to delete them. – ccot Jun 03 '20 at 17:09
  • It's been long I worked on the @edgeLambda, as far as I remember I was able to delete it on the go removing the association from the Cloudfront. I tried doing it again now just to check for you, able to delete the 1 replica out of 3 and on trying deleting the 2 replica ran into error saying can't delete as it is an replicated function , not sure about what is causing this as i remove all the associations already, may be have to wait for a while as you are facing. – DHEERAJ Jun 03 '20 at 18:29
  • Same error. But it seems the solution is just to wait enough time and try again lol (so I guess I'll wait) – Jerry Green Feb 20 '21 at 16:23
  • After deleting old versions and roles and permissions, I waited for about 15 mins and I was able to delete, as suggested. Ty! – NecipAllef Nov 07 '22 at 14:25
6

Replicated functions are something Lambda@Edge uses, so I assume that's the case here even though it's not stated. You should review this document on how to delete these. You can't manually delete them at this time:

You can delete a Lambda@Edge function only when the replicas of the function have been deleted by CloudFront. Replicas of a Lambda function are automatically deleted in the following situations:

After you have removed the last association for the function from all of your CloudFront distributions. If more than one distribution uses a function, the replicas are removed only after the function is disassociated from the last one.

After you delete the last distribution that a function was associated with.

Replicas are typically deleted within a few hours.

Note:

Replicas cannot be manually deleted at this time. This helps prevent a situation where a replica is removed that you're still using, which would result in an error.

Brandon Miller
  • 4,695
  • 1
  • 20
  • 27
  • thanks very much! I disabled the associated cloudfront distribution, and once that finishes I'll delete it, and I have a hunch that will allow me to delete the function -- I'll follow up once that's all done – duhaime Jun 07 '18 at 19:19
  • Yep, deleting my CloudFront distribution allowed me to delete the function -- many thanks! – duhaime Jun 07 '18 at 22:58
  • 7
    I deleted my cloudFront yet couldn't delete the lambda until an hour or so. Finally removed all code from the lambda (except one comment line) and saved it. Then I was able to get it deleted. – swateek Jan 06 '20 at 07:18
2

If you tried every other answer, and it's still not deleting - wait 5-10 minutes and try again.

kolobok
  • 3,835
  • 3
  • 38
  • 54
0

BHEERAJ's answer is good, but in my exact case I waited like 6 hours and nothing changed and the error was still ocurring, but then I also removed related S3 buckets (and to remove the bucket, I had to remove items inside it first):

https://s3.console.aws.amazon.com/s3

Then in about half a hour I tried to remove those Lambda functions, and finally it actually deleted.

Jerry Green
  • 1,244
  • 1
  • 15
  • 25