-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (55 loc) · 1.65 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
BASE_STACK_NAME=pr-notify
BUCKET?=my-bucket
STACK_NAME_SUFFIX?=$(USER)
TEAM=hexmatter
LOGGER=DEBUG
ifdef TARGET
TPL=cloudformation/$(TARGET).yaml
endif
ifdef ENV
OWNER=$(TEAM)
STACK_NAME_SUFFIX=$(ENV)
else
ENV=development
OWNER=$(USER)
endif
# CloudFormation stacks do not allow underscores but support dashes. Python package names support underscores
# but not dashes. The Stackname contains the component name (or TARGET) which is often the same as the package name.
# To prevent clashes we replace underscores with dashes.
TARGET_TPL=$(subst _,-,$(TARGET))
PACKAGED_TPL=$(TARGET_TPL)-packaged-cloudformation-template.yaml
sync:
mkdir -p _build/
cp -R src/* _build/
mkdir -p _build/configs
cp -R configs/ _build/configs/
build:
rm -rf _build && mkdir -p _build
pip install --upgrade pip
pip install -r requirements.txt -t _build
$(MAKE) sync
package:
@mkdir -p _build
@echo "Preparing and uploading AWS package for $(TPL) for $(TARGET_TPL)."
aws cloudformation package \
--template-file $(TPL) \
--s3-bucket $(BUCKET) \
--s3-prefix packages \
--output-template-file _build/$(PACKAGED_TPL) \
deploy:
@echo "Deploying template for $(TPL) for $(TARGET_TPL)."
aws cloudformation deploy \
--template-file _build/$(PACKAGED_TPL) \
--stack-name $(BASE_STACK_NAME)--$(TARGET_TPL)--$(STACK_NAME_SUFFIX) \
--capabilities CAPABILITY_IAM \
--parameter-overrides \
Environment=$(ENV) \
BucketName=$(BUCKET) \
GitHubToken=$(GITHUB_TOKEN) \
Owner=$(OWNER) \
LogLevel=$(LOGGER)
release:
@$(MAKE) build && $(MAKE) package && $(MAKE) deploy || echo "No changes to be deployed."
clean:
find . -name "*.pyc" -exec rm -f {} \;
rm -rf _build