-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
86 lines (73 loc) · 3.16 KB
/
Makefile
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
# This Makefile will exist in the 'root' directory *ONLY*
.DEFAULT_GOAL := check-aws-profile
check-aws-profile:
ifndef AWS_PROFILE
$(error AWS_PROFILE is undefined E.G export AWS_PROFILE=default)
endif
branch=`git rev-parse --abbrev-ref HEAD`
# Parameters
SolutionNamingBase=tutorial-system-frontend
SolutionNaming=${SolutionNamingBase}-${branch}
Locale=cicd
BRANCH_NAME=$(shell git rev-parse --abbrev-ref HEAD)
RepositoyName=tutorialsystem-frontend-controller
SlackChannel=
SlackURL=
SlackIcon=
### Deploy Tasks
.PHONY: test
test: check-aws-profile
aws cloudformation validate-template \
--template-body file://pipeline.yaml \
--region ap-southeast-1 --profile $(AWS_PROFILE)
.PHONY: update
update: check-aws-profile test
aws cloudformation update-stack \
--stack-name ${SolutionNaming}-cicd-pipeline-cf \
--template-body file://pipeline.yaml \
--parameters ParameterKey=pSolutionNaming,ParameterValue=$(SolutionNaming) \
ParameterKey=pGitHubOAuthToken,ParameterValue=$(GitHubOAuthToken) \
ParameterKey=pLocale,ParameterValue=$(Locale) \
ParameterKey=pBranchName,ParameterValue=$(BRANCH_NAME) \
ParameterKey=pRepositoyName,ParameterValue=$(RepositoyName) \
ParameterKey=pSlackChannel,ParameterValue=$(SlackChannel) \
ParameterKey=pSlackURL,ParameterValue=$(SlackURL) \
ParameterKey=pSlackIcon,ParameterValue=$(SlackIcon) \
--capabilities CAPABILITY_NAMED_IAM --region ap-southeast-1 --profile $(AWS_PROFILE)
.PHONY: deploy
deploy: check-aws-profile test
aws cloudformation create-stack \
--stack-name ${SolutionNaming}-cicd-pipeline-cf \
--template-body file://pipeline.yaml \
--parameters ParameterKey=pSolutionNaming,ParameterValue=$(SolutionNaming) \
ParameterKey=pGitHubOAuthToken,ParameterValue=$(GitHubOAuthToken) \
ParameterKey=pLocale,ParameterValue=$(Locale) \
ParameterKey=pBranchName,ParameterValue=$(BRANCH_NAME) \
ParameterKey=pRepositoyName,ParameterValue=$(RepositoyName) \
ParameterKey=pSlackChannel,ParameterValue=$(SlackChannel) \
ParameterKey=pSlackURL,ParameterValue=$(SlackURL) \
ParameterKey=pSlackIcon,ParameterValue=$(SlackIcon) \
--capabilities CAPABILITY_NAMED_IAM --region ap-southeast-1 --profile $(AWS_PROFILE)
.PHONY: destroy
destroy: check-aws-profile
-aws s3 rm s3://${SolutionNaming}-$(Locale)-pipeline-s3 --recursive --region ap-southeast-1 --profile $(AWS_PROFILE)
-aws s3 rb s3://${SolutionNaming}-$(Locale)-pipeline-s3 --region ap-southeast-1 --profile $(AWS_PROFILE) --force
aws cloudformation delete-stack \
--stack-name ${SolutionNaming}-cicd-pipeline-cf \
--profile $(AWS_PROFILE)
.PHONY: destroy-branch
destroy-branch:
aws s3 rm s3://${SolutionNamingBase}-${BRANCH}-$(Locale)-pipeline-s3 --recursive --region ap-southeast-1
aws s3 rb s3://${SolutionNamingBase}-${BRANCH}-$(Locale)-pipeline-s3 --region ap-southeast-1 --force
aws cloudformation delete-stack \
--stack-name ${SolutionNamingBase}-${BRANCH}-cicd-pipeline-cf
.PHONY: _events
_events: check-aws-profile
aws cloudformation describe-stack-events \
--stack-name ${SolutionNaming}-cicd-pipeline-cf \
--profile $(AWS_PROFILE)
.PHONY: _output
_output: check-aws-profile
aws cloudformation describe-stacks \
--stack-name ${SolutionNaming}-cicd-pipeline-cf \
--profile $(AWS_PROFILE)