@@ -3,32 +3,61 @@ export AWS_SECRET_ACCESS_KEY ?= test
33export AWS_DEFAULT_REGION =us-east-1
44SHELL := /bin/bash
55
6- usage : # # Show this help
7- @fgrep -h " ##" $(MAKEFILE_LIST ) | fgrep -v fgrep | sed -e ' s/\\$$//' | sed -e ' s/##//'
8-
9- install : # # Install dependencies
10- @which localstack || pip install localstack
11- @which awslocal || pip install awscli-local
12- @which tflocal || pip install terraform-local
13-
14- setup : # # Setup the architecture
15- awslocal s3 mb s3://covid19-lake; \
16- awslocal s3 cp CovidLakeStack.template.json s3://covid19-lake/cfn/CovidLakeStack.template.json; \
17- awslocal s3 sync ./covid19-lake-data/ s3://covid19-lake/; \
18- awslocal cloudformation create-stack --stack-name covid-lake-stack --template-url https://covid19-lake.s3.us-east-2.amazonaws.com/cfn/CovidLakeStack.template.json
19-
20- start : # # Start LocalStack in detached mode
21- localstack start -d
22-
23- stop : # # Stop the Running LocalStack container
24- @echo
25- localstack stop
26-
27- ready : # # Make sure the LocalStack container is up
28- @echo Waiting on the LocalStack container...
29- @localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)
6+ usage : # # Show this help in table format
7+ @echo " | Target | Description |"
8+ @echo " |------------------------|-------------------------------------------------------------------|"
9+ @fgrep -h " ##" $(MAKEFILE_LIST ) | fgrep -v fgrep | sed -e ' s/:.*##\s*/##/g' | awk -F' ##' ' { printf "| %-22s | %-65s |\n", $$1, $$2 }'
10+
11+ check : # # Check if all required prerequisites are installed
12+ @command -v docker > /dev/null 2>&1 || { echo " Docker is not installed. Please install Docker and try again." ; exit 1; }
13+ @command -v aws > /dev/null 2>&1 || { echo " AWS CLI is not installed. Please install AWS CLI and try again." ; exit 1; }
14+ @command -v awslocal > /dev/null 2>&1 || { echo " AWS CLI Local is not installed. Please install awslocal and try again." ; exit 1; }
15+ @command -v localstack > /dev/null 2>&1 || { echo " LocalStack is not installed. Please install LocalStack and try again." ; exit 1; }
16+ @command -v python > /dev/null 2>&1 || { echo " Python is not installed. Please install Python and try again." ; exit 1; }
17+ @echo " All required prerequisites are available."
18+
19+ deploy : # # Setup the architecture
20+ @echo " Deploying the architecture..."
21+ @echo " Create S3 bucket and upload the CloudFormation template..."
22+ awslocal s3 mb s3://covid19-lake; \
23+ awslocal s3 cp cloudformation-templates/CovidLakeStack.template.json s3://covid19-lake/cfn/CovidLakeStack.template.json; \
24+ awslocal s3 sync ./covid19-lake-data/ s3://covid19-lake/; \
25+ awslocal cloudformation create-stack --stack-name covid-lake-stack --template-url http://s3.localhost.localstack.cloud:4566/covid19-lake/cfn/CovidLakeStack.template.json
26+ @counter=0; \
27+ while [ $$ counter -lt 30 ]; do \
28+ status=$$(awslocal cloudformation describe-stacks --stack-name covid-lake-stack | grep StackStatus | cut -d'"' -f4 ) ; \
29+ echo " Attempt $$ counter: Stack status: $$ status" ; \
30+ if [ " $$ status" = " CREATE_COMPLETE" ]; then \
31+ echo " Stack creation completed successfully!" ; \
32+ exit 0; \
33+ fi ; \
34+ counter=$$((counter+1 ) ); \
35+ if [ $$ counter -lt 30 ]; then sleep 2; fi ; \
36+ done ; \
37+ echo " Stack creation timed out after 30 attempts" ; \
38+ exit 1
39+
40+ test : # # Run the tests
41+ @echo " Installing dependencies..."
42+ @pip install -r tests/requirements.txt
43+ @echo " Running tests..."
44+ pytest -s -v --disable-warnings tests/
45+ @echo " All tests completed successfully."
46+
47+ start : # # Start LocalStack
48+ @echo " Starting LocalStack..."
49+ @LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN ) IMAGE_NAME=localstack/localstack-pro:latest-bigdata localstack start -d
50+ @echo " LocalStack started successfully."
51+
52+ stop : # # Stop the Running LocalStack container
53+ @echo " Stopping LocalStack..."
54+ localstack stop
55+
56+ ready : # # Make sure the LocalStack container is up
57+ @echo Waiting on the LocalStack container...
58+ @localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)
3059
3160logs : # # Save the LocalStack logs in a separate file
32- @localstack logs > logs.txt
61+ @localstack logs > logs.txt
3362
3463.PHONY : usage install run start stop ready logs
0 commit comments