Skip to content

Instantly share code, notes, and snippets.

@SamTowne
Last active February 25, 2023 14:43
Show Gist options
  • Save SamTowne/9fb8e124781d231a99b53a047a46c6df to your computer and use it in GitHub Desktop.
Save SamTowne/9fb8e124781d231a99b53a047a46c6df to your computer and use it in GitHub Desktop.
Makefile for creating a lambda layer using venv (Unix)
default:
echo
prepdirs:
mkdir -p ./workspace/venv/layer
mkdir -p ./workspace/output/layer
createVirtualEnv: clearenv prepdirs
python3 -m venv ./workspace/venv
createlayer: createVirtualEnv
./workspace/venv/bin/pip3 install -t ./workspace/venv/layer/python3 boto3
./workspace/venv/bin/pip3 install -t ./workspace/venv/layer/python3 aws-xray-sdk
ziplayer: creatlayer
zip -r9 ./workspace/output/layer/lambdalayer.zip ./workspace/venv/layer/python3

Using the Lambda Layer Makefile

  1. Navigate to the location of the Makefile
  2. Invoke the ziplayer function
    • make ziplayer
  3. Use the generated .zip file as desired
    • The packages are zipped up to workspace/output/layer/lambdalayer.zip
  4. Optional - delete the workspace directory and everything in it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment