Create layer.sh file and copy paste following content run this file as sh layer.sh,
- This cmd will create layer
- Deploy layer to lambda function
- Mapp Layer ARN to lambda function
- It will also add Layer ARN to your zappa_setting.json file
-----------------------------Shell Script-------------------------------------
mkdir layer
apt install jq
pip install -r requirements.txt -t layer/python/
cd layer
zip -r9 ../layer.zip .
cd ..
# Deploy the Layer
LAYER_ARN=$(aws lambda publish-layer-version --layer-name zappa-layer --zip-file fileb://layer.zip --compatible-runtimes python3.9 --query LayerVersionArn --output text)
echo $LAYER_ARN
# Update Zappa settings with the new Layer ARN
jq --arg LAYER_ARN "$LAYER_ARN" '.dev.layers[0] = $LAYER_ARN' zappa_settings.json > tmp.json && mv tmp.json zappa_settings.json
rm -rf layer.zip layer