Delete a specific file within a Lambda function when cannot use Console Code Editor

0

Hello,

I deployed a package on Lambda, but I received the following error:

deployment package of your Lambda function is too large to enable inline code

I found that an extra, unnecessary file ended up in the exported ZIP package that pushed it over the 3 MB console editor limit as described here: https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#limits-list

I'd like to delete that single file from the function without having to remake the entire Lambda function from scratch from a new ZIP file, because of the extensive re-configuration and extra validation work on our end that would be needed to do that.

Since I can't access the console editor, however, I cannot simply right click the file and hit Delete like I would normally to delete the file.

So my question is: is it possible to check and delete a specific file within a Lambda function when we cannot use the console editor, either through AWS web API or the CLI?

Thank you for your help.

1 Answer
0

This is not possible and not recommended either. Lambda takes the zip file that you upload and does some processing internally with it. That artifact is not made available to users. So you will need to unzip the zip file, delete that culprit file and recreate the zip file and redeploy to lambda.

Ideally you should be using SAM or CDK or other tools like Terraform for deploying your Lambda functions and integrate them into a CI/CD pipeline.

A good workshop to get hands-on with SAM and AWS CI/CD services is here - https://cicd.serverlessworkshops.io/

profile pictureAWS
EXPERT
answered 2 years ago
  • Hello Indranil,

    Thank you very much for your help and suggestions!

    If it can't be done, it can't be done - but it's just frustrating because I could easily delete that superfluous file in the console editor with a simple right click -> Delete, were that editor actually available to me.

    But because I just happened to cross an arbitrary 3 MB limit, I have no console editor, so the files that comprise the function seem to be set in stone. Just wish there was a way to capture that same functionality in this case.

    Oh well, thanks anyway, and will check out the resources you mentioned.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions