EDIT:
So lambda function projects can be uploaded as zip files.
I think this lambdazip.sh is a shell script used to zip the project. I have been manually zipping the project through the Finder on my MacOS.
After I cd to my /bin, I run
sh lambdazip.zip
But I get the following error:
stephenstilwell@Stephens-MacBook-Air bin % sh lambdazip.sh
lambdazip.sh: line 6: cd: /lib/python2.7/site-packages/: No such file or directory
zip warning: name not matched: pypdftk*
zip error: Nothing to do! (/Users/stephenstilwell/Downloads/cl_boost-pdfgen-1.3.3-master/bin/dist/cl-boost.zip)
zip warning: name not matched: bin
zip error: Nothing to do! (try: zip -r /Users/stephenstilwell/Downloads/cl_boost-pdfgen-1.3.3-master/bin/dist/cl-boost.zip . -i bin)
zip warning: name not matched: boost*
zip warning: name not matched: pdf_surveys
zip error: Nothing to do! (/Users/stephenstilwell/Downloads/cl_boost-pdfgen-1.3.3-master/bin/dist/cl-boost.zip)
So I've been given a zipped file with no real instructions or documentation on what to do with the codebase.
My task is to get this project all set up on AWS.
The AWS Services in use will be Lambda, S3, Api Gateway, Simple Email Service.
To my current knowledge, I think this .sh file may have been used to test the lambda function locally before deployment to AWS Lambda, but I'm not sure.
Does this file need to be uploaded to the lambda function?
Does it belong in a Lambda Layer?
What is its purpose and why did the past developer use it?
lambdazip.sh
#!/bin/bash
PYTHON_PATH=$VIRTUAL_ENV/..
BASE_PATH=$PWD
cd $VIRTUAL_ENV/lib/python2.7/site-packages/
zip -x "*pyc" -r9 $BASE_PATH/dist/cl-boost.zip pypdftk*
cd $BASE_PATH
zip -r $BASE_PATH/dist/cl-boost.zip bin
cd $BASE_PATH
zip -x "*pyc" -r9 $BASE_PATH/dist/cl-boost.zip boost* pdf_surveys
CodePudding user response:
From what I see lambdazip.sh
is used to package dependencies from the project's virtual environment and from the project's base path.
What you probably have to do is enable VIRTUALENV
for the project by doing something like python2.7 -m virtualenv
or following this: enable VIRTUALENV. Afterwards you may want to install the dependencies in your virtual environment using pip
. You should be able to run lambdazip.sh
afterwards successfully.
CodePudding user response:
It looks like a helper for AWS Lambda function creation.
In case Lambda uses only core Python libraries, it's possible to just copy/paste its code to code editor in AWS Lambda Web UI.
But if you need some extra dependencies, you have two options:
- Put the dependencies into so-called AWS Lamda Layer (and then you can copy/paste the function code via UI, plus in Lambda settings you'll have to connect the Layer to the function)
- Put everything (both the function and its dependencies) into a ZIP archive and upload it as a Lambda function
If you choose the second option, you'll not be able to tweak code in visual editor (which may be useful during debugging).
I suggest that the lambdazip.sh
creates the ZIP file with the function and dependencies.