-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (49 loc) · 1.87 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
all: deploy
.PHONY: layers deploy package validate
PROJECT := Print2PDF
ENVIRONMENT ?= Test
STACK_NAME ?= Print2PDF$(ENVIRONMENT)
PACKAGE_TEMPLATE := template.yml
PACKAGE_BUCKET ?= chialab-cloudformation-templates
PACKAGE_PREFIX ?= chialab/print2pdf/$(shell git symbolic-ref --short HEAD)
PACKAGE_PROFILE ?= chialabsrl
DEPLOY_PROFILE ?= chialab
app:
aws s3 sync public/ s3://$(APP_BUCKET) --delete --profile $(DEPLOY_PROFILE)
aws cloudfront create-invalidation \
--distribution-id $(DISTRIBUTION_ID) \
--paths '/*' \
--profile $(DEPLOY_PROFILE)
layers:
docker run --rm \
-v $(PWD)/layers/puppeteer/nodejs:/var/task \
-e NODE_ENV=production \
-e PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 \
lambci/lambda:build-nodejs12.x \
npm $(if $(wildcard layers/puppeteer/nodejs/node_modules/*), rebuild, install)
yarn --cwd layers/uuid/nodejs install
ensure-layer-%:
@if ! [[ -d 'layers/$*/nodejs/node_modules' ]]; then \
printf '\033[31mDependencies for layer \033[1m%s\033[22m are not installed, run \033[1m%s\033[22m first!\033[0m\n' $* 'make layers'; \
exit 1; \
fi
deploy: package
aws cloudformation deploy \
--template-file $(PACKAGE_TEMPLATE) \
--stack-name $(STACK_NAME) \
--tags Project=$(PROJECT) Environment=$(ENVIRONMENT) \
--capabilities CAPABILITY_IAM \
--profile $(DEPLOY_PROFILE)
package: ensure-layer-puppeteer ensure-layer-uuid validate
aws cloudformation package \
--template-file templates/root.yml \
--output-template-file $(PACKAGE_TEMPLATE) \
--s3-bucket $(PACKAGE_BUCKET) \
--s3-prefix $(PACKAGE_PREFIX) \
--profile $(PACKAGE_PROFILE)
aws s3 cp $(PACKAGE_TEMPLATE) s3://$(PACKAGE_BUCKET)/$(PACKAGE_PREFIX)/ --profile $(PACKAGE_PROFILE)
@echo "https://$(PACKAGE_BUCKET).s3.amazonaws.com/$(PACKAGE_PREFIX)/$(PACKAGE_TEMPLATE)"
validate:
aws cloudformation validate-template \
--template-body file://templates/root.yml \
--profile $(PACKAGE_PROFILE)