Repository navigation
Expand file tree
/
Copy pathdeploy
More file actions
61 lines (53 loc) · 1.55 KB
/
Copy pathdeploy
File metadata and controls
61 lines (53 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
set -e
LAYER_NAME="parameter-store-extension"
REGIONS=(
ap-northeast-1
ap-northeast-2
ap-south-1
ap-southeast-1
ap-southeast-2
ca-central-1
eu-central-1
eu-west-1
eu-west-2
eu-west-3
sa-east-1
us-east-1
us-east-2
us-west-1
us-west-2
)
GIT_TAG=$1
if [ -z $GIT_TAG ]
then
echo "empty git tag"
exit 1
fi
if output=$(git status --porcelain --untracked-files=no) && [ -z "$output" ]; then
echo "Tagging ${GIT_TAG}"
else
echo "Working directory is not clean, exiting"
exit 1
fi
MSG="Parameter Store AWS Lambda Extension ${GIT_TAG}"
git tag -a "${GIT_TAG}" -m "${MSG}"
git push --follow-tags origin ${GIT_TAG}
for region in "${REGIONS[@]}"; do
echo "Publishing Parameter Store Lambda layer to ${region}..."
layer_version=$(aws lambda publish-layer-version \
--layer-name $LAYER_NAME \
--zip-file "fileb://extensions.zip" \
--description "${MSG}" \
--region $region \
--output text \
--query Version)
echo "published Parameter Store Lambda extension layer version ${layer_version} to ${region}"
echo "Setting public permissions for Parameter Store Lambda extension layer version ${layer_version} in ${region}"
output=$(aws lambda add-layer-version-permission \
--layer-name $LAYER_NAME \
--version-number $layer_version \
--statement-id public \
--action lambda:GetLayerVersion \
--principal "*" \
--region $region)
echo "Public permissions set for Parameter Store Lambda extension layer version ${layer_version} in region ${region}"