@@ -3,6 +3,7 @@ SHELL := /bin/bash
33-include .env-gdc-local
44
55CDIR = cd iac/awscdk
6+ TDIR = cd tests
67
78export APP_NAME? =ecslb
89export ENFORCE_IAM? =0
@@ -12,42 +13,70 @@ usage: ## Show this help in table format
1213 @echo " |------------------------|-------------------------------------------------------------------|"
1314 @fgrep -h " ##" $(MAKEFILE_LIST ) | fgrep -v fgrep | sed -e ' s/:.*##\s*/##/g' | awk -F' ##' ' { printf "| %-22s | %-65s |\n", $$1, $$2 }'
1415
16+ check : # # Check if all required prerequisites are installed
17+ @command -v docker > /dev/null 2>&1 || { echo " Docker is not installed. Please install Docker and try again." ; exit 1; }
18+ @command -v node > /dev/null 2>&1 || { echo " Node.js is not installed. Please install Node.js and try again." ; exit 1; }
19+ @command -v aws > /dev/null 2>&1 || { echo " AWS CLI is not installed. Please install AWS CLI and try again." ; exit 1; }
20+ @command -v localstack > /dev/null 2>&1 || { echo " LocalStack is not installed. Please install LocalStack and try again." ; exit 1; }
21+ @command -v cdk > /dev/null 2>&1 || { echo " CDK is not installed. Please install CDK and try again." ; exit 1; }
22+ @command -v cdklocal > /dev/null 2>&1 || { echo " cdklocal is not installed. Please install cdklocal and try again." ; exit 1; }
23+ @echo " All required prerequisites are available."
24+
25+ install : # # Install NPM dependencies
26+ @${CDIR} ; if [ ! -d " node_modules" ]; then \
27+ echo " Installing NPM dependencies..." ; \
28+ npm install; \
29+ else \
30+ echo " NPM dependencies for CDK project already installed." ; \
31+ fi
32+ @${TDIR} ; if [ ! -d " node_modules" ]; then \
33+ echo " Installing NPM dependencies..." ; \
34+ npm install; \
35+ else \
36+ echo " NPM dependencies for tests already installed." ; \
37+ fi
38+
39+ deploy : # # Bootstrap and deploy the CDK app on LocalStack
40+ ${CDIR} ; cdklocal bootstrap; cdklocal deploy --outputs-file ./output.json --json --require-approval never
41+
42+ deploy-aws : # # Bootstrap and deploy the CDK app on AWS
43+ ${CDIR} ; cdk bootstrap && \
44+ cdk deploy --outputs-file ./output.json --json
45+
46+ destroy : # # Destroy the deployed CDK stack on LocalStack
47+ ${CDIR} ; cdklocal destroy
1548
16- deploy : # # Bootstrap and deploy the CDK app to AWS
17- ${CDIR} ; cdk bootstrap; cdk deploy --outputs-file ./output.json --json
18-
19- destroy : # # Destroy the deployed CDK stack in AWS
49+ destroy-aws : # # Destroy the deployed CDK stack on AWS
2050 ${CDIR} ; cdk destroy
2151
22- destroy-local : # # Destroy the deployed CDK stack locally
23- ${CDIR} ; cdklocal destroy
24-
25- deploy-local : # # Bootstrap and deploy the CDK app locally
26- ${CDIR} ; cdklocal bootstrap && \
27- cdklocal deploy --outputs-file ./output.json --json --require-approval never
52+ test : # # Run integration tests on LocalStack
53+ cd tests && LOCALSTACK=1 npm run test
2854
29- test : # # Run integration tests
55+ test-aws : # # Run integration tests on AWS
3056 cd tests && npm run test
3157
32- test-local : # # Run integration tests
33- cd tests && LOCALSTACK=1 npm run test
34-
35- curl-local :
58+ curl : # # Curl the LocalStack service load balancer
3659 curl $(shell cat iac/awscdk/output.json | jq '.RepoStack.localstackserviceslb')
3760
38- curl-aws :
61+ curl-aws : # # Curl the AWS service load balancer
3962 curl $(shell cat iac/awscdk/output.json | jq '.RepoStack.serviceslb')
4063
41- install : # # Install npm dependencies
42- ${CDIR} ; npm install
43-
64+ start : # # Start LocalStack
65+ @echo " Starting LocalStack..."
66+ @LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN ) localstack start -d
67+ @echo " LocalStack started successfully."
4468
45- start-localstack :
46- cd devops-tooling && docker compose -p $(APP_NAME ) up
69+ stop : # # Stop LocalStack
70+ @echo " Stopping LocalStack..."
71+ @localstack stop
72+ @echo " LocalStack stopped successfully."
4773
48- stop-localstack :
49- cd devops-tooling && docker compose -p $(APP_NAME ) down
74+ ready : # # Make sure the LocalStack container is up
75+ @echo Waiting on the LocalStack container...
76+ @localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)
5077
78+ logs : # # Save the logs in a separate file
79+ @localstack logs > logs.txt
5180
5281PKG_SUB_DIRS := $(dir $(shell find . -type d -name node_modules -prune -o -type d -name "venv* " -prune -o -type f -name package.json -print) )
5382
@@ -56,4 +85,4 @@ update-deps: $(PKG_SUB_DIRS)
5685 pushd $$i && ncu -u && npm install && popd; \
5786 done
5887
59- .PHONY : usage install test test-local deploy destroy deploy-local destroy-local bootstrap-local update-deps start-localstack stop-localstack curl-local curl-aws
88+ .PHONY : usage install check start deploy curl test destroy logs deploy-aws curl-aws test-aws destroy-aws update-deps
0 commit comments