-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (81 loc) · 4.78 KB
/
Makefile
File metadata and controls
97 lines (81 loc) · 4.78 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
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
# This file is for you! Edit it to implement your own hooks (make targets) into
# the project as automated steps to be executed on locally and in the CD pipeline.
include scripts/init.mk
# ==============================================================================
# Example CI/CD targets are: dependencies, build, publish, deploy, clean, etc.
dependencies: # Install dependencies needed to build and test the project @Pipeline
./scripts/workflow/install-python-dependencies.sh
build: # Build the project artefacts @Pipeline
./scripts/workflow/build-project-artefacts.sh
publish: # Publish the project artefacts @Pipeline
./scripts/workflow/publish-built-artefacts.sh
deploy-local: build # Deploy the project artefact to the target environment @Pipeline
echo "Deploying to localstack"
echo "Pre-requisites: Docker is running; Localstack is running"
(cd src; ./deploy.sh localstack)
deploy: build
echo "Deploying to AWS"
echo "Pre-requisites: AWS credentials are configured"
(cd src; ./deploy.sh aws)
(cd src; ./deploy-apis.sh)
deploy-sandbox: build
echo "Deploying to localstack"
echo "Pre-requisites: Docker is running; Localstack is running"
(cd src; ./deploy-sandbox.sh localstack)
update-local: build
echo "Updating local lambdas"
(cd src; ./update.sh)
clean-local:
docker ps | grep triageapilambda | awk '{print $$1}' | xargs --no-run-if-empty docker rm -f
clean-slate: clean-local
rm -rf .venv
rm -f .coverage coverage_report.txt src/lambda_function.zip
find . | grep --extended-regexp "/__pycache__" | xargs rm -rf
localstack restart || localstack start --detached
make dependencies
SKIP_DEPS=true make test-coverage test-lint
clean:: # Clean-up project resources (main) @Operations
echo "Deleting subscription filter..."
aws logs delete-subscription-filter --log-group-name /aws/lambda/triageApiLambda-apig --filter-name triageApiLambda-apig-filter || echo "Subscription filter not found"
echo "Deleting LambdaS3ReadAccess role policy..."
aws iam delete-role-policy --role-name triageApiLambda-ex-role --policy-name LambdaS3ReadAccess || echo "LambdaS3ReadAccess role policy not found"
echo "Deleting AWSLambdaBasicExecutionRole role policy..."
aws iam detach-role-policy --role-name triageApiLambda-ex-role --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole || echo "AWSLambdaBasicExecutionRole role policy not found"
echo "Deleting AWSXRayDaemonWriteAccess role policy..."
aws iam detach-role-policy --role-name triageApiLambda-ex-role --policy-arn arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess || echo "AWSXRayDaemonWriteAccess role policy not found"
echo "Deleting AWSLambdaDynamoDBExecutionRole role policy..."
aws iam detach-role-policy --role-name triageApiLambda-ex-role --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole || echo "AWSLambdaDynamoDBExecutionRole role policy not found"
echo "Deleting DynamoDBLambdaAccess role policy..."
aws iam delete-role-policy --role-name triageApiLambda-ex-role --policy-name DynamoDBLambdaAccess || echo "DynamoDBLambdaAccess role policy not found"
echo "Deleting triageApiLambda-ex-role role..."
aws iam delete-role --role-name triageApiLambda-ex-role || echo "Role not found"
echo "Deleting triageApiLambda-apig function..."
aws lambda delete-function --function-name triageApiLambda-apig || echo "Function not found"
echo "Deleting triageApiLambda-s3 function..."
aws lambda delete-function --function-name triageApiLambda-s3 || echo "Function not found"
echo "Deleting triageApiLambda-log-stream function..."
aws lambda delete-function --function-name triageApiLambda-log-stream || echo "Function not found"
echo "Deleting pathways-data-bucket bucket..."
aws s3 rm 's3://pathways-data-bucket' --recursive || echo "Bucket not found"
aws s3api delete-bucket --bucket pathways-data-bucket || echo "Bucket not found"
echo "Deleting StartingCoords table..."
aws dynamodb delete-table --table-name StartingCoords --no-cli-pager || echo "Table not found"
aws dynamodb wait table-not-exists --table-name StartingCoords
echo "Deleting TriageNodes table..."
aws dynamodb delete-table --table-name TriageNodes --no-cli-pager || echo "Table not found"
aws dynamodb wait table-not-exists --table-name TriageNodes
echo "Deleting BodyMaps table..."
aws dynamodb delete-table --table-name BodyMaps --no-cli-pager || echo "Table not found"
aws dynamodb wait table-not-exists --table-name BodyMaps
chmod +x ./src/delete-apis.sh
(cd src; ./delete-apis.sh)
config:: # Configure development environment (main) @Configuration
# TODO: Use only 'make' targets that are specific to this project, e.g. you may not need to install Node.js
make _install-dependencies
# ==============================================================================
${VERBOSE}.SILENT: \
build \
clean \
config \
dependencies \
deploy \