-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
32 lines (26 loc) · 1.15 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
SHELL := /usr/bin/env bash
OUT_DIR = dist
TEMPLATE_FILE=template.yml
AWS_DEFAULT_REGION ?= $(shell aws configure get region)
CF_BUCKET=cloudformation-`aws sts get-caller-identity --output text --query 'Account'`-$(AWS_DEFAULT_REGION)
ENV ?= $(shell aws configure get environment)
STACK_NAME=rds-events-to-cloudwatch-$(ENV)
# Check if variable has been defined, otherwise print custom error message
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))
install:
@pip install -r requirements.txt
check-bucket:
@aws s3api head-bucket --bucket $(CF_BUCKET) &> /dev/null || aws s3 mb s3://$(CF_BUCKET)
package: check-bucket
@mkdir $(OUT_DIR) &> /dev/null || true
@sam package --s3-bucket $(CF_BUCKET) --template-file $(TEMPLATE_FILE) --output-template-file $(OUT_DIR)/$(TEMPLATE_FILE)
lint-templates:
@cfn-lint
deploy: package lint-templates
$(call check_defined, ENV, Ex: make deploy ENV=dev)
@sam deploy --template-file $(OUT_DIR)/$(TEMPLATE_FILE) --stack-name $(STACK_NAME) --parameter-overrides Environment=$(ENV) --capabilities CAPABILITY_IAM