How to recover lambda code or edit it inline after uploading huge sized zip file to the aws lambda?

11,557

Yes, you can download the Lambda function. Go to the AWS console for the Lambda function, make sure you are in the Configuration view, then click Actions | Export function. This will allow you to download a ZIP file containing the Lambda function.

Note that once you upload a Lambda function via S3, it's copied by the Lambda service. There's no connection at that point back to the S3 object that you uploaded. One reason for this is that your Lambda function would break if you, accidentally or otherwise, deleted the file from S3.

enter image description here

Share:
11,557
Chintan Thakkar
Author by

Chintan Thakkar

Updated on June 06, 2022

Comments

  • Chintan Thakkar
    Chintan Thakkar almost 2 years

    Firstly, I am a newbie to AWS. I was able to edit my Lambda code in line, but I recently uploaded a zip file to it(30MB) to S3 bucket and added this zip to my Lambda from S3, and now my Lambda inline editor doesn't open anymore saying the following error

    "The deployment package of your Lambda function "LF2" is too large to enable inline code editing. However, you can still invoke your function."

    I tried deleting my zip file from S3 bucket hoping that the URL of zip would not be reachable and the lambda would lose the zip file and let me edit the function again. But, my lambda size still consists of the 30MB zip file size. I am unable to delete this zip and can't figure out a way to get rid of this it and edit my lambda code again.

    Note: My Lambda code was written in-line and different from the zip file(which only contains elastic search setup files which I uploaded for using in my code since import elastic search wasn't working). I know there would have been a better way to do this without uploading it's zip.

    Screenshot

  • Chintan Thakkar
    Chintan Thakkar about 5 years
    This downloads only the zip file which I uploaded, not my Python Lambda code. I need to edit my Python code in line or atleast retrieve the code. How do i do it?
  • Chintan Thakkar
    Chintan Thakkar about 5 years
    Thanks for the explanation jarmod about how lambda service copies s3 object. But, I have updated my description with a note. I am not uploading my lambda via S3, I had my lambda code in line and I just tried uploading the elasticsearch library zip file via s3 since 'import elasticsearch' wasn't working.
  • jarmod
    jarmod about 5 years
    The ZIP file that you uploaded to Lambda becomes your new Lambda function, replacing the previous one. If it's not actually a valid function, that's immaterial, unfortunately. Do you have a backup of the original source code?
  • Chintan Thakkar
    Chintan Thakkar about 5 years
    Sad, I didn't know it would replace my code, I thought it was there to add any external dependencies or so. Unfortunately, I don't have any backup since I didn't expect this. Seems I may to do it all again :( Thanks.
  • jarmod
    jarmod about 5 years
    Sorry, I know that's painful. I can't think of an obvious way to recover the source if you don't have a backup of it. That said, be aware that if you develop outside of the Lambda console then you can easily package and deploy into Lambda. And if you code within the Lambda console then you can export the code (per above). You can also enable versioning on the Lambda function but that's not really a solution to the problem you ran into (because it's related to publishing functions, not making simple code changes).
  • Will
    Will almost 3 years
    Just tried, doesn't work anymore seemingly unfortunately
  • qre0ct
    qre0ct over 2 years
    @Will what does not work?
  • Admin
    Admin over 2 years
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.