Skip to content

Commit 3d7eb7a

Browse files
committed
Add support for a staging publish
1 parent aca1dbe commit 3d7eb7a

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ build:
1010
publish:
1111
@$(PWD)/publish.sh
1212

13+
publish-staging:
14+
@$(PWD)/publish-staging.sh
15+
1316
.PHONY: \
1417
build
15-
publish
18+
publish
19+
publish-staging

publish-staging.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash -e
2+
3+
# AWS Regions
4+
REGIONS=(
5+
"us-west-2"
6+
)
7+
LAYER_NAME="bash-testing"
8+
9+
for region in ${REGIONS[@]}; do
10+
echo "Publishing layer to $region..."
11+
12+
LAYER_ARN=$(aws lambda publish-layer-version --region $region --layer-name $LAYER_NAME --description "Bash in AWS Lambda [https://github.com/gkrizek/bash-lambda-layer]" --compatible-runtimes provided --license MIT --zip-file fileb://export/layer.zip | jq -r .LayerVersionArn)
13+
14+
echo $LAYER_ARN
15+
echo "$region complete for Staging"
16+
echo ""
17+
done
18+
19+
echo "Successfully published to all regions"

publish.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ REGIONS=(
1919
"eu-west-3"
2020
"sa-east-1"
2121
)
22+
LAYER_NAME="bash"
2223

2324
for region in ${REGIONS[@]}; do
2425
echo "Publishing layer to $region..."
2526

26-
LAYER_ARN=$(aws lambda publish-layer-version --region $region --layer-name bash --description "Bash in AWS Lambda [https://github.com/gkrizek/bash-lambda-layer]" --compatible-runtimes provided --license MIT --zip-file fileb://export/layer.zip | jq -r .LayerVersionArn)
27-
POLICY=$(aws lambda add-layer-version-permission --region $region --layer-name bash --version-number $(echo -n $LAYER_ARN | tail -c 1) --statement-id bash-public --action lambda:GetLayerVersion --principal \*)
27+
LAYER_ARN=$(aws lambda publish-layer-version --region $region --layer-name $LAYER_NAME --description "Bash in AWS Lambda [https://github.com/gkrizek/bash-lambda-layer]" --compatible-runtimes provided --license MIT --zip-file fileb://export/layer.zip | jq -r .LayerVersionArn)
28+
POLICY=$(aws lambda add-layer-version-permission --region $region --layer-name $LAYER_NAME --version-number $(echo -n $LAYER_ARN | tail -c 1) --statement-id $LAYER_NAME-public --action lambda:GetLayerVersion --principal \*)
2829

2930
echo $LAYER_ARN
3031
echo "$region complete"

0 commit comments

Comments
 (0)