forked from stackery/php-lambda-layer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.sh
executable file
·22 lines (16 loc) · 1.19 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
#!/bin/bash -e
source regions.sh
PHP_VERSION="${1}"
LAYER="php${PHP_VERSION//.}"
MD5SUM=$(md5 -q "${LAYER}.zip")
S3KEY="${LAYER}/${MD5SUM}"
for region in "${PHP_REGIONS[@]}"; do
bucket_name="stackery-layers-${region}"
echo "Publishing Lambda Layer ${LAYER} in region ${region}..."
# Must use --cli-input-json so AWS CLI doesn't attempt to fetch license URL
version=$(aws --region $region lambda publish-layer-version --cli-input-json "{\"LayerName\": \"${LAYER}\",\"Description\": \"PHP ${PHP_VERSION} Web Server Lambda Runtime\",\"Content\": {\"S3Bucket\": \"${bucket_name}\",\"S3Key\": \"${S3KEY}\"},\"CompatibleRuntimes\": [\"provided\"],\"LicenseInfo\": \"http://www.php.net/license/3_01.txt\"}" --output text --query Version)
echo "Published Lambda Layer ${LAYER} in region ${region} version ${version}"
echo "Setting public permissions on Lambda Layer ${LAYER} version ${version} in region ${region}..."
aws --region $region lambda add-layer-version-permission --layer-name "${LAYER}" --version-number $version --statement-id=public --action lambda:GetLayerVersion --principal '*' > /dev/null
echo "Public permissions set on Lambda Layer ${LAYER} version ${version} in region ${region}"
done