-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.sample
103 lines (88 loc) · 5.6 KB
/
Makefile.sample
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
.PHONY: all build package copycodeww copytemplateww creates3 deletes3 deploy deployw quick
# set bucket name prefix to be created
bucket = <ENTER S3 BUCKET NAME TO HOLD DEPLOYMENT ARTIFACTS>
# can set multiple AWS regions separated by space
regions = <ENTER ONE OR MORE AWS REGION CODE TO DEPLOY. Example: eu-west-1>
# regions = ap-southeast-1 ap-southeast-2 ap-northeast-1 ap-northeast-2 ap-south-1 ca-central-1 eu-west-1 eu-west-2 eu-west-3 eu-north-1 sa-east-1 us-east-1 us-east-2 us-west-2
# set to AWS CLI profile name to use
profile = <ENTER THE AWS CLI PROFILE NAME. Example: default>
# Version details for the deployment. This would be used to upload deployment assets into the version folder in S3 bucket
version = v01
# set Stack Name
stack_name = ivsqos$(version)
# set the name of Docket Image which will be build
docker_image = ivsqos$(version)
# Version details for the deployment. This would be used to upload deployment assets into the version folder in S3 bucket
playback_url = <Enter playback URL>
# Set the OpenSearch ARN here
opensearch_arn = <Enter ARN for OpenSearch>
all: clean image build package copycodeww copytemplateww
image:
docker build --tag amazonlinux:${docker_image} .
build:
docker run --rm --volume ${PWD}/lambda-functions/deploy-function:/build amazonlinux:${docker_image} /bin/bash -c "npm init -f -y; npm install adm-zip --save; npm install generate-password --save; npm install mime --save; npm install --only=prod"
docker run --rm --volume ${PWD}/lambda-functions/playersummary-cw-function:/build amazonlinux:${docker_image} /bin/bash -c "npm init -f -y; npm install --only=prod"
docker run --rm --volume ${PWD}/lambda-functions/quizsummary-cw-function:/build amazonlinux:${docker_image} /bin/bash -c "npm init -f -y; npm install --only=prod"
docker run --rm --volume ${PWD}/lambda-functions/add-partition-function:/build amazonlinux:${docker_image} /bin/bash -c "npm init -f -y; npm install --only=prod"
mkdir -p ${PWD}/lambda-functions/record-validation-function/package
docker run -it --rm --volume ${PWD}/lambda-functions/record-validation-function:/build amazonlinux:${docker_image} /bin/bash -c "pip install --target=./package -r requirements.txt"
package:
mkdir -p dist
cd lambda-functions/deploy-function && zip -x \.* event.json \*.yaml -FS -q -r ../../dist/deploy-function.zip * && cd ../..
cd lambda-functions/playersummary-cw-function && zip -FS -q -r ../../dist/playersummary-cw-function.zip * && cd ../..
cd lambda-functions/quizsummary-cw-function && zip -FS -q -r ../../dist/quizsummary-cw-function.zip * && cd ../..
cd lambda-functions/add-partition-function && zip -FS -q -r ../../dist/add-partition-function.zip * && cd ../..
cd web/ && zip -FS -q -r ../dist/player-ui.zip * && cd ../..
cd lambda-functions/record-validation-function/package && zip -FS -q -r ../../../dist/record-validation-function.zip * && cd .. && zip -g ../../dist/record-validation-function.zip *.py && zip -g ../../dist/record-validation-function.zip *.json && cd ../../..
cd lambda-functions/event-bridge-handler-function && zip -FS -q -r ../../dist/event-bridge-handler-function.zip * && cd ../..
creates3:
@for region in $(regions);do \
echo $$region; echo $(bucket); \
aws s3 mb s3://$(bucket)-$$region --region $$region --profile $(profile); \
done
deletes3:
@for region in $(regions);do \
echo $$region; echo $(bucket); \
aws s3 rb s3://$(bucket)-$$region --force --profile $(profile); \
done
copycodeww:
@for region in $(regions) ; do \
echo $$region; echo $(bucket);\
aws s3 cp dist/player-ui.zip s3://$(bucket)-$$region/qos/$(version)/lambda-functions/ui-deployment/user-interfaces/ --profile $(profile); \
done
copytemplateww:
@for region in $(regions);do \
echo $$region; echo $(bucket); \
sed -e "s/BUCKET_NAME/${bucket}/g" -e "s/VERSION/${version}/g" templates/deployment_template.yaml > templates/deployment_package.yaml; \
aws cloudformation package --template-file templates/deployment_package.yaml --s3-bucket $(bucket)-$$region --s3-prefix deploy/lambda-functions --output-template-file templates/deployment.yaml --profile $(profile); \
aws s3 cp templates/deployment.yaml s3://$(bucket)-$$region/qos/templates/$(version)/ --profile $(profile); \
done
template:
sed -e "s/BUCKET_NAME/${bucket}/g" -e "s/VERSION/${version}/g" templates/deployment_template.yaml > templates/deployment_package.yaml
distpackage:
@for region in $(regions);do \
echo $$region; echo $(bucket); \
aws cloudformation package --template-file templates/deployment_package.yaml --s3-bucket $(bucket)-$$region --s3-prefix deploy/lambda-functions --output-template-file templates/deployment.yaml --profile $(profile); \
deploy:
@for region in $(regions);do \
echo $$region; echo $(bucket); \
aws cloudformation deploy --template-file templates/deployment.yaml \
--stack-name $(stack_name) --capabilities=CAPABILITY_NAMED_IAM --profile $(profile) --region $$region \
--s3-bucket $(bucket)-$$region \
--parameter-overrides DeployDemoUI=true PlaybackURL=${playback_url}; \
done
deployw:
@for region in $(regions);do \
echo $$region; echo $(bucket); \
aws cloudformation deploy --template-file templates/deployment.yaml \
--stack-name $(stack_name) --capabilities=CAPABILITY_NAMED_IAM --profile $(profile) --region $$region \
--s3-bucket $(bucket)-$$region \
--parameter-overrides DeployDemoUI=true PlaybackURL=${playback_url} PushToOpenSearch=true OpenSearchDomainArn=${opensearch_arn}; \
done
clean:
rm -rf dist/*
rm -rf lambda-functions/deploy-function/node_modules/*
rm -rf lambda-functions/record-validation-function/package/*
cleandocker:
docker rmi --force amazonlinux:${docker_image}
quick: copytemplateww deploy