lambda-git icon indicating copy to clipboard operation
lambda-git copied to clipboard

Can't view lambda once library is uploaded

Open tomisaacson opened this issue 6 years ago • 2 comments

I'm not sure how I'm supposed to use your installation $ pip install lambda-git for lambda. I tried zipping the files and adding them that way but when I use the web UI I get the error:

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

tomisaacson avatar May 24 '19 03:05 tomisaacson

This isn't a limitation with lambda-git so much as it is with AWS's in-browser lambda function editor. AWS limits the total size of a lambda you're allowed to edit through the AWS console (their web UI) to 3 MB (see here for an overview and here for more information about Lambda deployment limits. When the size of your lambda exceeds that limit, you're met with the message you quoted rather than an editor.

If you're missing having the convenience of the console editor, a natural workaround is to create a Lambda Layer that contains just the lambda-git library and then add that Layer to any Lambda Function where you wish to have access to the library. This has the added advantage of encouraging code reuse across your Lambda Functions.

See the documentation I linked for Layers above for more info. One simple approach is to …

  1. Create a top level directory for a new zip file. I'll use /tmp/lambda-git-layer for the sake of argument.
  2. Create a /tmp/lambda-git-layer/python subdirectory. This is the simples of several choices of directory structures that AWS Lambda recognizes within a Python layer.
  3. Call pip install --target /tmp/lambda-git-layer/python lambda-git to install lambda-git into /tmp/lambda-git-layer/python
  4. Zip up the /tmp/lambda-git-layer directory into, say, lambda-git-layer.zip
  5. Create a layer out of lambda-git-layer.zip using your preferred tool (AWS CLI, AWS console, etc.)

You can now configure a Lambda Function to use that Layer. Once you've done so, you should be able to import git in that function as you'd expect.

drmrd avatar Aug 01 '19 23:08 drmrd

Understood, but my point is that your instructions just say $ pip install lambda-git. I'm not sure how that's supposed to work if you're just using the basic lambda upload.

tomisaacson avatar Aug 02 '19 02:08 tomisaacson