The script will generate a Zipped Lambda layer in the support strucutre, and it can be safely uploaded and used as part of your Lambda function.
Last active
February 24, 2023 13:10
-
-
Save akmalharith/61d7c9d99b9bdeeb7c59353f4e2dc2a5 to your computer and use it in GitHub Desktop.
Install requirements and build a Lambda layer compatible zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [[ ! -f package.json ]] ; then | |
echo "File package.json doesn't exist. Run npm init and npm install first." | |
exit | |
fi | |
npm ci | |
mkdir -p dist/lambda_layer/nodejs/node_modules | |
cp -r node_modules dist/lambda_layer/nodejs/ | |
cd dist/lambda_layer && zip -r lambda_layer.zip nodejs | |
mv lambda_layer.zip ../. | |
cd .. && rm -fr lambda_layer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
mkdir -p build/lambda_layer/python | |
pip install -r requirements.txt -t build/lambda_layer/python | |
cd build/lambda_layer && zip -r lambda_layer.zip python | |
mv lambda_layer.zip ../. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment