-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (40 loc) · 1.48 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
# Configure the build by setting the environment variables below.
# The default values should allow you to create a development stack.
APP_NAME ?= quickbase-sentiment-analysis
APP_STAGE ?= $(USER)
AWS_REGION ?= $(shell aws configure get region)
# Common values used throughout the Makefile, not intended to be configured.
CODE_BUCKET = $(APP_NAME)-code-$(AWS_REGION)-$(APP_STAGE)
STACK_NAME = $(APP_NAME)-$(APP_STAGE)
PACKAGED_TEMPLATE = packaged.yaml
TEMPLATE = template.yaml
TEMPLATE_PARAMS = Domain=$(STACK_NAME)
.PHONY: build
build:
(cd function && npm install)
.PHONY: run
run:
sam local start-api
.PHONY: code-bucket
code-bucket:
aws s3 mb s3://$(CODE_BUCKET)
.PHONY: package
package:
sam package --template-file $(TEMPLATE) --s3-bucket $(CODE_BUCKET) --output-template-file $(PACKAGED_TEMPLATE)
.PHONY: deploy
deploy: package
sam deploy --template-file $(PACKAGED_TEMPLATE) --stack-name $(STACK_NAME) --capabilities CAPABILITY_IAM --parameter-overrides $(TEMPLATE_PARAMS)
.PHONY: settings
settings:
$(eval FUNC := $(shell aws cloudformation describe-stacks --query "Stacks[0].Outputs[?OutputKey=='MetadataFunction'].OutputValue | [0]" --output text --stack-name $(STACK_NAME)))
aws lambda invoke --function-name $(FUNC) settings.json
.PHONY: publish
publish: package
sam publish --template $(PACKAGED_TEMPLATE) --region $(AWS_REGION)
.PHONY: teardown
teardown:
aws cloudformation delete-stack --stack-name $(STACK_NAME)
.PHONY: clean
clean:
rm -f $(PACKAGED_TEMPLATE)
rm -f settings.json