#!/bin/bash -eu if [ $# -ne 1 ]; then echo >&2 "Usage: $0 " exit 1 fi dir="$1" if [ ! -d "$dir" ]; then echo >&2 "Directory does not exist: $dir" exit 1 fi # Get basename of realpath for layer name name=$(basename "$(realpath "$dir")") REGION=$(aws configure get region) # Prepare zip file cd "$dir" zip="../$name.zip" rm -f "$zip" zip -r -X -q "$zip" . -x __pycache__/\* \*.pyc # Create or update layer aws lambda publish-layer-version \ --layer-name "$name" \ --description "$dir" \ --zip-file "fileb://$zip" \ --region "$REGION" # printf "Published layer %s version %s\n" \ # "$(echo "$response" | jq -r '.LayerName')" \ # "$(echo "$response" | jq -r '.Version')"