.PHONY: all build package copycodeww copytemplateww creates3 deletes3 deploy deployw quick # set bucket name prefix to be created bucket = # can set multiple AWS regions separated by space regions = # 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 = # 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 = # Set the OpenSearch ARN here opensearch_arn = 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