-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (74 loc) · 2.54 KB
/
Makefile
File metadata and controls
102 lines (74 loc) · 2.54 KB
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
92
93
94
95
96
97
98
99
100
101
################################################################################
#
# rds_engine_settings
#
################################################################################
ifndef VERBOSE
.SILENT:
endif
RM = rm -f
ECHO = echo -e
TAG = etags
PIP = pip
PYTHON = python3
SHELL = /bin/bash
WHICH = /usr/bin/which
WATCH = /usr/bin/watch
TEST = /usr/bin/test
ZIP = /usr/bin/zip
SRC = function.py
AWS = aws
VENV ?= .venv
VENV_ACTIVATE =. $(VENV)/bin/activate
ALIAS_NAME ?= $(shell bash -c 'read -p "Alias name: " alias; echo $$alias')
STACK :=lambda-function-rds-engine-settings
FUNCTION_NAME :=rds_engine_settings
ifndef BUCKET_NAME
BUCKET_NAME :=lambda-dev-eu-west-1
endif
export VIRTUAL_ENV := $(abspath ${VENV})
export PATH := ${VIRTUAL_ENV}/bin:${PATH}
all : venv template package
${VENV} :
$(PYTHON) -m venv $@
venv-install : requirements_dev.txt | ${VENV}
$(PIP) install -U pip
$(PIP) install --upgrade -r requirements_dev.txt
venv :
test -d ${VENV} || $(MAKE) venv-install
$(VENV_ACTIVATE)
$(WHICH) python
clean-template :
$(RM) $(FUNCTION_NAME).yml
clean : clean-template
$(RM) $(FUNCTION_NAME).zip
template : clean-template package $(VENV_ACTIVATE)
$(AWS) cloudformation package --s3-bucket $(BUCKET_NAME) \
--template-file function_template.yml \
--output-template-file $(FUNCTION_NAME).yml
package : clean
$(ZIP) -r9 $(FUNCTION_NAME).zip $(SRC)
create : template $(VENV_ACTIVATE)
$(AWS) cloudformation create-stack --stack-name $(STACK) \
--template-body file://$(FUNCTION_NAME).yml \
--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_IAM
update : template publish $(VENV_ACTIVATE)
$(AWS) cloudformation update-stack --stack-name $(STACK) \
--template-body file://$(FUNCTION_NAME).yml \
--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_IAM
delete : clean-template
$(AWS) cloudformation delete-stack --stack-name $(STACK)
validate : $(VENV_ACTIVATE)
$(AWS) cloudformation validate-template \
--template-body file://$(FUNCTION_NAME).yml
events : $(VENV_ACTIVATE)
$(AWS) cloudformation describe-stack-events \
--stack-name $(STACK) \
--region $(AWS_REGION)
pytest : $(VENV_ACTIVATE)
pytest test_rds.py
cfntest : $(VENV_ACTIVATE)
aws cloudformation create-stack --stack-name TestLambda --template-body file://test_template.yml
watch :
$(WATCH) --interval 1 "bash -c 'make events | head -40'"
.PHONY : all venv venv-install clean clean-template package publish pytest