forked from binaris/lambda-runtime-pypy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·47 lines (40 loc) · 1.34 KB
/
publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash -eu
publicize=0
while getopts "p" opt
do
case $opt in
(p) publicize=1 ;;
(*) exit 1 ;;
esac
done
source conf.sh
RUNTIME_ZIP="${PYPY_VERSION}.zip"
MD5SUM=$(type -P md5 && md5 -q $RUNTIME_ZIP || md5sum $RUNTIME_ZIP | awk '{ print $1 }')
PYPY=${PYPY_VERSION//-*}
S3KEY="${PYPY}/${MD5SUM}.zip"
for region in "${PYPY_REGIONS[@]}"; do
bucket_name="${bucket_base_name}-${region}"
echo "Publishing Lambda Layer ${PYPY} in region ${region}..."
version=$(aws lambda publish-layer-version \
--layer-name ${PYPY//.} \
--description "${PYPY} Lambda Runtime" \
--content "S3Bucket=${bucket_name},S3Key=${S3KEY}" \
--compatible-runtimes provided \
--license-info "MIT" \
--output text \
--query Version \
--region $region)
echo "Published Lambda Layer ${PYPY} in region ${region} version ${version}"
if (( publicize )); then
echo "Setting public permissions on Lambda Layer ${PYPY} version ${version} in region ${region}..."
aws lambda add-layer-version-permission \
--layer-name ${PYPY//.} \
--version-number $version \
--statement-id public \
--action lambda:GetLayerVersion \
--principal "*" \
--region $region \
> /dev/null
echo "Public permissions set on Lambda Layer ${PYPY} version ${version} in region ${region}"
fi
done