-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
91 lines (77 loc) · 2.58 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
87
88
89
90
91
FUNCTION_NAME?=BankOfEngland__ExchangeRates
STACK_NAME?=Lambda$(FUNCTION_NAME)
.PHONY: setup
setup:
aws configure --profile $(STACK_NAME)
.PHONY: create
create: zip
unset AWS_DEFAULT_REGION; \
aws configure --profile $(PROFILE); \
aws cloudformation create-stack \
--profile $(STACK_NAME) \
--stack-name $(STACK_NAME) \
--capabilities CAPABILITY_IAM \
--template-body file://lambda.yml \
--tags Key=Name,Value=$(FUNCTION_NAME) \
--parameters ParameterKey=Environment,ParameterValue=$(REGION) > /dev/null; \
sleep 61; \
aws lambda update-function-code \
--profile $(PROFILE) \
--function-name $(FUNCTION_NAME) \
--zip-file fileb://function.zip > /dev/null
.PHONY: update
update: zip
unset AWS_DEFAULT_REGION; \
aws configure --profile $(PROFILE); \
aws cloudformation update-stack \
--profile $(STACK_NAME) \
--stack-name $(STACK_NAME)\
--capabilities CAPABILITY_IAM \
--template-body file://lambda.yml \
--tags Key=Name,Value=$(FUNCTION_NAME) \
--parameters ParameterKey=Environment,ParameterValue=$(REGION) > /dev/null; \
aws lambda update-function-code \
--profile $(PROFILE) \
--function-name $(FUNCTION_NAME)\
--zip-file fileb://function.zip > /dev/null
.PHONY: zip
zip:
@-rm -f *.zip
@zip -r function.zip lambda_function.py > /dev/null
.PHONY: pipeline
pipeline:
$(eval REPOSITORY_NAME := $(shell basename $$PWD))
-@unset AWS_DEFAULT_REGION; \
aws configure --profile $(PROFILE); \
aws cloudformation create-stack \
--profile $(STACK_NAME) \
--stack-name Pipeline$(STACK_NAME) \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \
--template-body file://pipeline.yml \
--output text \
--parameters \
ParameterKey=Environment,ParameterValue=$(REGION) \
ParameterKey=StackName,ParameterValue=$(STACK_NAME) \
ParameterKey=RepositoryName,ParameterValue=$(REPOSITORY_NAME)
.PHONY: update_pipeline
update_pipeline:
$(eval REPOSITORY_NAME := $(shell basename $$PWD))
-@unset AWS_DEFAULT_REGION; \
aws configure --profile $(STACK_NAME); \
aws cloudformation update-stack \
--profile $(PROFILE) \
--stack-name Pipeline$(STACK_NAME) \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \
--template-body file://pipeline.yml \
--output text \
--parameters \
ParameterKey=Environment,ParameterValue=$(REGION) \
ParameterKey=StackName,ParameterValue=$(STACK_NAME) \
ParameterKey=RepositoryName,ParameterValue=$(REPOSITORY_NAME) > /dev/null
.PHONY: release
release: update_pipeline
@git status
$(eval COMMENT := $(shell bash -c 'read -e -p "Comment: " var; echo $$var'))
@git add --all; \
git commit -m "$(COMMENT)"; \
git push