-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
60 lines (51 loc) · 1.56 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
PROJECT = serverless-qiita-team-template
SRC ?= $(shell go list ./... | grep -v vendor)
TESTARGS ?= -v
define encrypt
aws kms encrypt \
--key-id "${KMS_KEY_ID}" \
--query CiphertextBlob \
--output text \
--plaintext $(1)
endef
deps:
dep ensure
.PHONY: deps
test:
go test $(SRC) $(TESTARGS)
.PHONY: test
fmt:
go fmt $(SRC)
.PHONY: fmt
build:
GOARCH=amd64 GOOS=linux go build -o build/$(PROJECT)
.PHONY: build
mb:
aws s3 mb s3://$(PROJECT)
.PHONY: mb
deploy:
aws cloudformation package \
--template-file template.yaml \
--s3-bucket $(PROJECT) \
--output-template-file .template-output.yml
aws cloudformation deploy \
--template-file .template-output.yml \
--stack-name $(PROJECT) \
--capabilities CAPABILITY_IAM \
--parameter-overrides \
QiitaAccessToken="$(shell $(call encrypt, ${QIITA_ACCESS_TOKEN}))" \
QiitaTeamName="$(shell $(call encrypt, ${QIITA_TEAM_NAME}))" \
QiitaTeamTemplateId="$(shell $(call encrypt, ${QIITA_TEAM_TEMPLATE_ID}))" \
KmsKeyId="${KMS_KEY_ID}" \
ScheduleExpression="${SCHEDULE_EXPRESSION}"
.PHONY: deploy
destroy:
aws cloudformation delete-stack \
--stack-name $(PROJECT)
aws s3 rb --force s3://$(PROJECT)
.PHONY: destroy
invoke_local:
echo "" | sam local invoke \
--parameter-values \
QiitaAccessToken="$(shell $(call encrypt, ${QIITA_ACCESS_TOKEN}))",QiitaTeamName="$(shell $(call encrypt, ${QIITA_TEAM_NAME}))",QiitaTeamTemplateId="$(shell $(call encrypt, ${QIITA_TEAM_TEMPLATE_ID}))",KmsKeyId="${KMS_KEY_ID}",ScheduleExpression="${SCHEDULE_EXPRESSION}"
.PHONY: invoke_local