79079896

Date: 2024-10-11 23:06:38
Score: 0.5
Natty:
Report link

Create layer.sh file and copy paste following content run this file as sh layer.sh,

  1. This cmd will create layer
  2. Deploy layer to lambda function
  3. Mapp Layer ARN to lambda function
  4. 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
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Filler text (0.5): -----------------------------
  • Filler text (0): -------------------------------------
  • Low reputation (1):
Posted by: kunal Roy