-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (71 loc) · 2.62 KB
/
Copy pathMakefile
File metadata and controls
89 lines (71 loc) · 2.62 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
SHELL := /bin/bash
.PHONY : help init deploy test clean delete
.DEFAULT: help
VENV_NAME ?= .venv
PYTHON ?= $(VENV_NAME)/bin/python
CUSTOM_FILE ?= .custom.mk
help:
@echo "init generate project for local development"
@echo "deploy deploy solution from source"
@echo "test run pre-commit checks"
@echo "clean delete virtualenv and installed libraries"
@echo "delete delete deployed stacks"
# Initialize VirtualEnv
.PHONY: $(VENV_NAME)
init: $(VENV_NAME)
$(VENV_NAME): pre-commit
$(VENV_NAME)/bin/activate: requirements.txt
test -d $(VENV_NAME) || virtualenv -p python3 $(VENV_NAME)
$(PYTHON) -m pip install -U pip
$(PYTHON) -m pip install -Ur requirements.txt
touch $(VENV_NAME)/bin/activate
pre-commit: $(VENV_NAME)/bin/activate
GIT_CONFIG=/dev/null $(VENV_NAME)/bin/pre-commit install
.PHONY: config package build
config: $(CUSTOM_FILE)
@echo "Configuration completed."
$(CUSTOM_FILE):
ifneq ("$(wildcard $(CUSTOM_FILE))","")
@echo "File $(CUSTOM_FILE) already exists. Change configuration manually in `./custom.mk` file if required."
endif
include $(CUSTOM_FILE)
deploy: package
@printf "\n--> Deploying %s template...\n" $(STACK_NAME)
@$(VENV_NAME)/bin/aws cloudformation deploy \
--template-file ./cfn/packaged.template \
--stack-name $(STACK_NAME) \
--region $(AWS_REGION) \
--capabilities CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \
--parameter-overrides \
AvailabilityZones=$(AWS_REGION)a,$(AWS_REGION)b \
UserPassword=$(USER_PASSWORD) \
MyPublicIP=$(MY_IP)
package: build
@printf "\n--> Packaging and uploading templates to the %s S3 bucket ...\n" $(BUCKET_NAME)
@$(VENV_NAME)/bin/aws cloudformation package \
--template-file ./cfn/main.template \
--s3-bucket $(BUCKET_NAME) \
--s3-prefix $(STACK_NAME) \
--output-template-file ./cfn/packaged.template \
--region $(AWS_REGION)
build:
@for fn in custom-resource/*; do \
printf "\n--> Installing %s requirements...\n" $${fn}; \
pip install -r $${fn}/requirements.txt --target $${fn} --upgrade; \
done
# Package for cfn-publish CI
cfn-publish-package: build
zip -r packaged.zip -@ < ci/include.lst
test:
$(VENV_NAME)/bin/pre-commit run --show-diff-on-failure --color=always --all-files
version:
@bumpversion --dry-run --list cfn/main.template | grep current_version | sed s/'^.*='//
# Cleanup local build
clean:
rm -rf $(VENV_NAME)
find . -iname "*.pyc" -delete
delete:
@printf "\n--> Deleting %s stack...\n" $(STACK_NAME)
@$(VENV_NAME)/bin/aws cloudformation delete-stack \
--stack-name $(STACK_NAME)
@printf "\n--> $(STACK_NAME) deletion has been submitted, check AWS CloudFormation Console for an update..."