@@ -4,70 +4,77 @@ SHELL := /usr/bin/env bash
44DEBUG := false
55ifeq ($(strip $(DEBUG ) ) ,true)
66 TF_LOG := DEBUG
7- TG_FLAGS := --terragrunt -debug
7+ TG_FLAGS := --inputs -debug
88endif
99
1010MODE := apply
1111ifeq ($(strip $(MODE ) ) ,apply)
12- MODE_STR := apply -auto-approve
12+ MODE_STR := --non-interactive -- apply -auto-approve
1313else ifeq ($(strip $(MODE)),destroy)
14- MODE_STR := destroy -auto-approve
14+ MODE_STR := --non-interactive -- destroy -auto-approve
1515else
16- MODE_STR := plan
16+ MODE_STR := --non-interactive -- plan
1717endif
1818
19+ PARTITION := aws
1920
2021ENV := dev
2122
23+ ifeq ($(strip $(PARTITION ) ) ,eusc)
24+ DEPLOY_PATH := stage/eusc/$(ENV)
25+ else
26+ DEPLOY_PATH := stage/$(ENV)
27+ endif
28+
2229init : prepare
23- cd stage/ $( ENV ) && terragrunt run- all init -upgrade=true
30+ cd $( DEPLOY_PATH ) && terragrunt run -- all -- init -upgrade=true
2431
2532run-one : prepare # # setup one EC2 instance from environment, usage: make run-one INSTANCE=instance-ubuntu [ENV=dev] [MODE=apply]
2633ifndef INSTANCE
2734 $(error Env INSTANCE is not defined. Usage make run-one ENV=dev INSTANCE=ubuntu)
2835endif
29- cd stage/$(ENV )/${INSTANCE} && terragrunt init -upgrade=true && terragrunt validate && terragrunt $(MODE_STR) --non-interactive $(TG_FLAGS)
36+ cd $(DEPLOY_PATH )/${INSTANCE} && terragrunt init -upgrade=true && terragrunt validate && terragrunt $(MODE_STR) $(TG_FLAGS)
3037
3138run : init # # setup EC2 instances for environment, usage: make run [ENV=dev] [MODE=apply]
32- @cd stage/ $( ENV ) && terragrunt run- all validate && terragrunt run- all $(MODE_STR ) --non-interactive $(TG_FLAGS )
39+ @cd $( DEPLOY_PATH ) && terragrunt run -- all validate && terragrunt run -- all $(MODE_STR ) $(TG_FLAGS )
3340
3441ssh : # # ssh to EC2 instance
3542ifndef INSTANCE
3643 $(error Env INSTANCE is not defined. Usage make ssh ENV=dev INSTANCE=ubuntu)
3744endif
38- ssh -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_rsa.aws.vm ubuntu@$(shell cd stage/$(ENV )/${INSTANCE} && terragrunt output ec2_dns)
45+ ssh -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_rsa.aws.vm ubuntu@$(shell cd $(DEPLOY_PATH )/${INSTANCE} && terragrunt output ec2_dns)
3946
4047ssm-ssh : # # ssh to EC2 instance over SSM SSH
4148ifndef INSTANCE
4249 $(error Env INSTANCE is not defined. Usage make ssm-ssh ENV=dev INSTANCE=ubuntu)
4350endif
44- aws ssm start-session --target "$(shell cd stage/$(ENV )/${INSTANCE} && terragrunt output ec2_id)"
51+ aws ssm start-session --target "$(shell cd $(DEPLOY_PATH )/${INSTANCE} && terragrunt output ec2_id)"
4552
4653destroy-instance : # # terminate instance
4754ifndef INSTANCE
4855 $(error Env INSTANCE is not defined. Usage make destroy-instance ENV=dev INSTANCE=ubuntu)
4956endif
50- aws ec2 terminate-instances --instance-ids "$(shell cd stage/$(ENV )/${INSTANCE} && terragrunt output ec2_id)"
57+ aws ec2 terminate-instances --instance-ids "$(shell cd $(DEPLOY_PATH )/${INSTANCE} && terragrunt output ec2_id)"
5158
5259show-instance-startup-logs : # show EC2 cloud-init startup logs
5360ifndef INSTANCE
5461 $(error Env INSTANCE is not defined. Usage make destroy-instance ENV=dev INSTANCE=ubuntu)
5562endif
56- ssh -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_rsa.aws.vm ubuntu@$(shell cd stage/$(ENV )/${INSTANCE} && terragrunt output ec2_dns) cat /var/log/cloud-init-output.log
63+ ssh -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_rsa.aws.vm ubuntu@$(shell cd $(DEPLOY_PATH )/${INSTANCE} && terragrunt output ec2_dns) cat /var/log/cloud-init-output.log
5764
5865show-instance-startup-script : # show EC2 cloud-init startup script
5966ifndef INSTANCE
6067 $(error Env INSTANCE is not defined. Usage make destroy-instance ENV=dev INSTANCE=ubuntu)
6168endif
62- ssh -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_rsa.aws.vm ubuntu@$(shell cd stage/$(ENV )/${INSTANCE} && terragrunt output ec2_dns) sudo cat /var/lib/cloud/instance/cloud-config.txt
69+ ssh -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_rsa.aws.vm ubuntu@$(shell cd $(DEPLOY_PATH )/${INSTANCE} && terragrunt output ec2_dns) sudo cat /var/lib/cloud/instance/cloud-config.txt
6370
6471
6572test : # # test Nginx instance
66- curl http://$(shell cd stage/ $( ENV ) /${INSTANCE} && terragrunt output ec2_dns) :80
73+ curl http://$(shell cd $( DEPLOY_PATH ) /${INSTANCE} && terragrunt output ec2_dns) :80
6774
6875
6976show-state : # # show state
70- cd stage/ $( ENV ) /${INSTANCE} && terragrunt state list && terragrunt show
77+ cd $( DEPLOY_PATH ) /${INSTANCE} && terragrunt state list && terragrunt show
7178
7279
7380clean : # # clean cached plugins and data
0 commit comments