Skip to content

Commit 76ce692

Browse files
committed
Added scripts for building the layer archive and for deploying it to multiple regions
1 parent 716675e commit 76ce692

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

layer/build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
echo "Building layer archive..."
4+
cd nodejs || exit
5+
npm install
6+
cd ../
7+
8+
output_zip=slappforge-lambda-debug-layer-"$(date +'%Y-%m-%d')".zip
9+
zip -r "${output_zip}" nodejs
10+
echo "Build Archive: ${output_zip}"

layer/deploy.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
LAYER_NAME=slappforge-debug-nodejs
4+
LAYER_BUILD_VERSION=1-0-0-build-01
5+
6+
# shellcheck disable=SC2039
7+
read -r -p "Name of the deployment archive: " deploymentArchive
8+
# shellcheck disable=SC2039
9+
read -r -p "AWS profile name: " profileName
10+
11+
layerName=${LAYER_NAME}-${LAYER_BUILD_VERSION}
12+
13+
# shellcheck disable=SC2039
14+
lambdaRegions=(us-east-1 us-east-2 us-west-1 us-west-2 ap-east-1 ap-south-1 ap-northeast-2 ap-southeast-1
15+
ap-southeast-2 ap-northeast-1 ca-central-1 eu-central-1 eu-west-1 eu-west-2 eu-west-3 eu-north-1 sa-east-1)
16+
17+
# shellcheck disable=SC2039
18+
echo "Publishing layer: ${layerName} ..."
19+
# shellcheck disable=SC2039
20+
for region in "${lambdaRegions[@]}"; do
21+
printf "%s " "${region}"
22+
23+
layerVersion=$(aws lambda publish-layer-version \
24+
--region "${region}" \
25+
--layer-name "${layerName}" \
26+
--description "SLAppForge Live Debug for AWS - NodeJS ${LAYER_BUILD_VERSION}" \
27+
--zip-file fileb://"${deploymentArchive}" \
28+
--compatible-runtimes nodejs10.x nodejs12.x \
29+
--profile "${profileName}" \
30+
--query Version)
31+
32+
aws lambda add-layer-version-permission \
33+
--region "${region}" \
34+
--layer-name "${layerName}" \
35+
--version-number "${layerVersion}" \
36+
--statement-id "GlobalPermVer${layerVersion}" \
37+
--action "lambda:GetLayerVersion" \
38+
--principal "*" \
39+
--profile "${profileName}" > /dev/null
40+
41+
echo "arn:aws:lambda:${region}:892904900711:layer:${layerName}:${layerVersion}"
42+
done

0 commit comments

Comments
 (0)