Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling headless deployment in make file #154

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 26 additions & 72 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#################################################################################

PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
HEADLESS = false

# Arguments defined through command line or config.yaml

Expand Down Expand Up @@ -239,90 +240,43 @@ listStacks:
buildEcsDeployer:
@cd ./ecs_model_deployer && npm install && npm run build

define print_config
@printf "\n \
DEPLOYING $(STACK) STACK APP INFRASTRUCTURE \n \
-----------------------------------\n \
Account Number $(ACCOUNT_NUMBER)\n \
Region $(REGION)\n \
App Name $(APP_NAME)\n \
Deployment Stage $(DEPLOYMENT_STAGE)\n \
Deployment Name $(DEPLOYMENT_NAME)"
@if [ -n "$(PROFILE)" ]; then \
printf "\n Deployment Profile $(PROFILE)"; \
fi
@printf "\n-----------------------------------\n"
endef

## Deploy all infrastructure
deploy: dockerCheck dockerLogin cleanMisc modelCheck buildEcsDeployer
ifdef PROFILE
@printf "\n \
DEPLOYING $(STACK) STACK APP INFRASTRUCTURE \n \
-----------------------------------\n \
Deployment Profile ${PROFILE}\n \
Account Number ${ACCOUNT_NUMBER}\n \
Region ${REGION}\n \
App Name ${APP_NAME}\n \
Deployment Stage ${DEPLOYMENT_STAGE}\n \
Deployment Name ${DEPLOYMENT_NAME}\n \
-----------------------------------\n \
Is the configuration correct? [y/N] "\
&& read confirm_config &&\
if \
[ $${confirm_config:-'N'} = 'y' ]; \
then \
npx cdk deploy ${STACK} \
--profile ${PROFILE} \
-c ${ENV}='$(shell echo '${${ENV}}')'; \
fi;
$(call print_config)
ifneq (,$(findstring true, $(HEADLESS)))
npx cdk deploy ${STACK} $(if $(PROFILE),--profile ${PROFILE}) --require-approval never -c ${ENV}='$(shell echo '${${ENV}}')';
else
@printf "\n \
DEPLOYING $(STACK) STACK APP INFRASTRUCTURE \n \
-----------------------------------\n \
Account Number ${ACCOUNT_NUMBER}\n \
Region ${REGION}\n \
App Name ${APP_NAME}\n \
Deployment Stage ${DEPLOYMENT_STAGE}\n \
Deployment Name ${DEPLOYMENT_NAME}\n \
-----------------------------------\n \
Is the configuration correct? [y/N] "\
@printf "Is the configuration correct? [y/N] "\
&& read confirm_config &&\
if \
[ $${confirm_config:-'N'} = 'y' ]; \
then \
npx cdk deploy ${STACK} \
-c ${ENV}='$(shell echo '${${ENV}}')'; \
if [ $${confirm_config:-'N'} = 'y' ]; then \
npx cdk deploy ${STACK} $(if $(PROFILE),--profile ${PROFILE}) -c ${ENV}='$(shell echo '${${ENV}}')'; \
fi;
endif


## Tear down all infrastructure
destroy: cleanMisc
ifdef PROFILE
@printf "\n \
DESTROYING $(STACK) STACK APP INFRASTRUCTURE \n \
-----------------------------------\n \
Deployment Profile ${PROFILE}\n \
Account Number ${ACCOUNT_NUMBER}\n \
Region ${REGION}\n \
App Name ${APP_NAME}\n \
Deployment Stage ${DEPLOYMENT_STAGE}\n \
Deployment Name ${DEPLOYMENT_NAME}\n \
-----------------------------------\n \
Is the configuration correct? [y/N] "\
$(call print_config)
@printf "Is the configuration correct? [y/N] "\
&& read confirm_config &&\
if \
[ $${confirm_config:-'N'} = 'y' ]; \
then \
npx cdk destroy ${STACK} \
--force \
--profile ${PROFILE}; \
fi;
else
@printf "\n \
DESTROYING $(STACK) STACK APP INFRASTRUCTURE \n \
-----------------------------------\n \
Account Number ${ACCOUNT_NUMBER}\n \
Region ${REGION}\n \
App Name ${APP_NAME}\n \
Deployment Stage ${DEPLOYMENT_STAGE}\n \
Deployment Name ${DEPLOYMENT_NAME}\n \
-----------------------------------\n \
Is the configuration correct? [y/N] "\
&& read confirm_config &&\
if \
[ $${confirm_config:-'N'} = 'y' ]; \
then \
npx cdk destroy ${STACK} \
--force; \
if [ $${confirm_config:-'N'} = 'y' ]; then \
npx cdk destroy ${STACK} --force $(if $(PROFILE),--profile ${PROFILE}); \
fi;
endif


#################################################################################
Expand Down
Loading