-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (39 loc) · 1.63 KB
/
Makefile
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
SHELL=/bin/bash
IMAGE_NAME=customergauge/aws-secretsmanager-caching-sidecar
build-docker-image:
docker build . -t ${IMAGE_NAME}:extension --target build-extension
docker build . -t ${IMAGE_NAME}
publish-docker-image: build-docker-image
(test $(TAG_VERSION)) && echo "Tagging images with \"${TAG_VERSION}\"" || echo "You have to define environment variable TAG_VERSION"
test $(TAG_VERSION)
docker image tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${TAG_VERSION}
docker image push ${IMAGE_NAME}:latest
docker image push ${IMAGE_NAME}:${TAG_VERSION}
build-lambda-extension: build-docker-image
mkdir -p .build/extensions
rm -f .build/extension.zip
CID=$$(docker create --entrypoint=scratch ${IMAGE_NAME}:extension) ; \
docker cp $${CID}:/cache-server .build/extensions
cd .build; zip -qq -y -r extension.zip extensions
publish-lambda-extension: build-lambda-extension
declare -a REGIONS=( "eu-west-1" "us-east-1" "ap-southeast-2" ) ; \
for region in "$${REGIONS[@]}" ; do \
layerVersion=$$(aws lambda publish-layer-version \
--region $$region \
--layer-name 'secretsmanager-caching-extension' \
--description 'Cache secret server extension' \
--license-info LGPLv3 \
--output text \
--query Version \
--zip-file fileb://.build/extension.zip) ; \
aws lambda add-layer-version-permission \
--output text \
--query RevisionId \
--region $$region \
--layer-name 'secretsmanager-caching-extension' \
--version-number $$layerVersion \
--statement-id public \
--action 'lambda:GetLayerVersion' \
--principal '*'; \
done
.PHONY: publish-docker-image build-docker-image publish-lambda-extension build-lambda-extension