|
| 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