lambda-git
lambda-git copied to clipboard
Can't view lambda once library is uploaded
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.
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 …
- Create a top level directory for a new zip file. I'll use
/tmp/lambda-git-layerfor the sake of argument. - Create a
/tmp/lambda-git-layer/pythonsubdirectory. This is the simples of several choices of directory structures that AWS Lambda recognizes within a Python layer. - Call
pip install --target /tmp/lambda-git-layer/python lambda-gitto install lambda-git into/tmp/lambda-git-layer/python - Zip up the
/tmp/lambda-git-layerdirectory into, say,lambda-git-layer.zip - Create a layer out of
lambda-git-layer.zipusing 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.
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.