-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
112 lines (91 loc) · 2.3 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# -*- mode: Makefile -*-
#
# Bucket in us-east-1 (per lambda@edge requirements)
PACKAGE_OUTPUT_BUCKET = nod15c.lambda-edge
# TODO from folder name
STACK_NAME = FileShare
OUTPUT_TEMPLATE = .packaged.yaml
STAGE = dev
# Lambda edge must be in us-east-1
DEPLOY_REGION = us-east-1
# List of targets that are not files
.PHONY: \
all \
check \
validate \
compile \
compile-clean \
test \
build \
clean \
package \
deploy \
errors \
outputs
SHELL=/usr/bin/env bash -o pipefail
check-dependency = $(if $(shell command -v $(1)),,$(error Please install $(1)))
makefiles = $(shell find . -mindepth 2 -maxdepth 2 -type f -name 'makefile')
subdirs := $(foreach proj,$(makefiles),$(dir $(proj)))
check:
@$(call check-dependency,aws)
@$(call check-dependency,jq)
@echo "Dirs: $(subdirs)"
@echo "Try: make build, make test, make deploy"
compile:
@for dir in $(subdirs); do \
$(MAKE) -C $$dir ; \
done
compile-clean:
@for dir in $(subdirs); do \
$(MAKE) -C $$dir clean; \
done
test:
@set -e; for dir in $(subdirs); do \
cd $$dir; \
npm run test; \
done
clean: compile-clean
@rm -rf .aws-sam
@rm -f $$OUTPUT_TEMPLATE
build: compile
@sam build
validate:
@sam validate
package: build
@sam package \
--output-template-file $(OUTPUT_TEMPLATE) \
--s3-bucket $(PACKAGE_OUTPUT_BUCKET) \
--region $(DEPLOY_REGION)
$(OUTPUT_TEMPLATE): package
deploy: $(OUTPUT_TEMPLATE)
@sam deploy \
--template-file $(OUTPUT_TEMPLATE) \
--stack-name $(STACK_NAME) \
--capabilities CAPABILITY_NAMED_IAM \
--region $(DEPLOY_REGION)
# changeset: $(OUTPUT_TEMPLATE)
# @aws cloudformation deploy \
# --no-execute-changeset \
# --template-file $(OUTPUT_TEMPLATE) \
# --stack-name $(STACK_NAME) \
# --capabilities CAPABILITY_NAMED_IAM \
# --region $(DEPLOY_REGION)
output:
@aws cloudformation describe-stacks \
--stack-name $(STACK_NAME) \
--query 'Stacks[].Outputs' \
--output table
destroy:
@aws cloudformation delete-stack \
--stack-name $(STACK_NAME) \
--region $(DEPLOY_REGION)
errors:
@aws cloudformation describe-stack-events \
--stack-name $(STACK_NAME) \
--region $(DEPLOY_REGION) \
| jq '.StackEvents[]|select(.ResourceStatus|index("FAILED"))'
outputs:
@aws cloudformation describe-stacks \
--stack-name $(STACK_NAME) \
--region $(DEPLOY_REGION) \
| jq '.Stacks[].Outputs'