Skip to content

Commit 68fd9c5

Browse files
committed
Update deployment scripts for multiple PHP version layers
1 parent 4a02416 commit 68fd9c5

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

Diff for: publish.sh

+12-9
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22

33
source regions.sh
44

5-
MD5SUM=$(md5 -q php71.zip)
6-
S3KEY="php71/${MD5SUM}"
5+
PHP_VERSION="${1}"
76

8-
for region in "${PHP71_REGIONS[@]}"; do
7+
LAYER="php${PHP_VERSION//.}"
8+
MD5SUM=$(md5 -q "${LAYER}.zip")
9+
S3KEY="${LAYER}/${MD5SUM}"
10+
11+
for region in "${PHP_REGIONS[@]}"; do
912
bucket_name="stackery-layers-${region}"
1013

11-
echo "Publishing Lambda Layer php71 in region ${region}..."
14+
echo "Publishing Lambda Layer ${LAYER} in region ${region}..."
1215
# Must use --cli-input-json so AWS CLI doesn't attempt to fetch license URL
13-
version=$(aws --region $region lambda publish-layer-version --cli-input-json "{\"LayerName\": \"php71\",\"Description\": \"PHP 7.1 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)
14-
echo "Published Lambda Layer php71 in region ${region} version ${version}"
16+
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)
17+
echo "Published Lambda Layer ${LAYER} in region ${region} version ${version}"
1518

16-
echo "Setting public permissions on Lambda Layer php71 version ${version} in region ${region}..."
17-
aws --region $region lambda add-layer-version-permission --layer-name php71 --version-number $version --statement-id=public --action lambda:GetLayerVersion --principal '*' > /dev/null
18-
echo "Public permissions set on Lambda Layer php71 version ${version} in region ${region}"
19+
echo "Setting public permissions on Lambda Layer ${LAYER} version ${version} in region ${region}..."
20+
aws --region $region lambda add-layer-version-permission --layer-name "${LAYER}" --version-number $version --statement-id=public --action lambda:GetLayerVersion --principal '*' > /dev/null
21+
echo "Public permissions set on Lambda Layer ${LAYER} version ${version} in region ${region}"
1922
done

Diff for: regions.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PHP71_REGIONS=(
1+
PHP_REGIONS=(
22
ap-northeast-1
33
ap-northeast-2
44
ap-south-1

Diff for: unpublish.sh

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/bin/bash -e
22

3-
VERSION=$1
3+
PHP_VERSION="${1}"
4+
LAYER_VERSION="${2}"
45

56
source regions.sh
67

7-
MD5SUM=$(md5 -q php71.zip)
8-
S3KEY="php71/${MD5SUM}"
8+
LAYER="php${PHP_VERSION//.}"
9+
MD5SUM=$(md5 -q "${LAYER}.zip")
10+
S3KEY="${LAYER}/${MD5SUM}"
911

10-
for region in "${PHP71_REGIONS[@]}"; do
12+
for region in "${PHP_REGIONS[@]}"; do
1113
bucket_name="stackery-layers-${region}"
1214

13-
echo "Deleting Lambda Layer php71 version ${VERSION} in region ${region}..."
14-
aws --region $region lambda delete-layer-version --layer-name php71 --version-number $VERSION > /dev/null
15-
echo "Deleted Lambda Layer php71 version ${VERSION} in region ${region}"
15+
echo "Deleting Lambda Layer ${LAYER} version ${VERSION} in region ${region}..."
16+
aws --region $region lambda delete-layer-version --layer-name ${LAYER} --version-number $VERSION > /dev/null
17+
echo "Deleted Lambda Layer ${LAYER} version ${VERSION} in region ${region}"
1618
done

Diff for: upload.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
source regions.sh
44

5-
MD5SUM=$(md5 -q php71.zip)
6-
S3KEY="php71/${MD5SUM}"
5+
PHP_VERSION="${1}"
76

8-
for region in "${PHP71_REGIONS[@]}"; do
7+
LAYER="php${PHP_VERSION//.}"
8+
MD5SUM=$(md5 -q "${LAYER}.zip")
9+
S3KEY="${LAYER}/${MD5SUM}"
10+
11+
for region in "${PHP_REGIONS[@]}"; do
912
bucket_name="stackery-layers-${region}"
1013

11-
echo "Uploading php71.zip to s3://${bucket_name}/${S3KEY}"
14+
echo "Uploading ${LAYER}.zip to s3://${bucket_name}/${S3KEY}"
1215

13-
aws --region $region s3 cp php71.zip "s3://${bucket_name}/${S3KEY}"
16+
aws --region $region s3 cp ${LAYER}.zip "s3://${bucket_name}/${S3KEY}"
1417
done

0 commit comments

Comments
 (0)