-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathcommon.mk
More file actions
65 lines (51 loc) · 2.19 KB
/
Copy pathcommon.mk
File metadata and controls
65 lines (51 loc) · 2.19 KB
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
# Shared Makefile logic for the LocalStack Terraform samples.
#
# Include it from a sample directory:
#
# include ../common.mk
#
# Customise a sample by setting any of these variables BEFORE the include:
# TEST_CMD - command run by the `test` target (default: ./run.sh)
# INIT_CMD - command run by the `init` target (default: lstk terraform init)
# DEPLOY_CMD - command run by the `deploy` target (default: lstk terraform apply)
# INSTALL_EXTRA - extra command run by the `install` target (default: check for terraform)
# DEPLOY_STEPS - targets chained by `run` and `test-ci` (default: start install init deploy test)
#
# Use `=` (deferred) for any value that references $(LSTK) or $(PYTHON_BIN),
# since those are defined below, after the point the sample sets its overrides.
export AWS_ACCESS_KEY_ID ?= test
export AWS_SECRET_ACCESS_KEY ?= test
export AWS_DEFAULT_REGION ?= us-east-1
SHELL := /bin/bash
PYTHON_BIN ?= $(shell which python3 || which python)
LSTK := lstk --non-interactive
TEST_CMD ?= ./run.sh
INIT_CMD ?= $(LSTK) terraform init
DEPLOY_CMD ?= $(LSTK) terraform apply --auto-approve
INSTALL_EXTRA ?= @which terraform || (echo 'Terraform was not found';)
DEPLOY_STEPS ?= start install init deploy test
usage: ## Show this help
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
start: ## Start LocalStack
@test -n "${LOCALSTACK_AUTH_TOKEN}" || (echo "LOCALSTACK_AUTH_TOKEN is not set" && exit 1);
DEBUG=1 LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) $(LSTK) start
stop: ## Stop LocalStack
$(LSTK) stop
logs: ## Write the LocalStack logs to logs.txt
@$(LSTK) logs > logs.txt
install: ## Install dependencies
@which lstk || brew install localstack/tap/lstk
$(INSTALL_EXTRA)
init: ## Initialize Terraform
$(INIT_CMD)
deploy: ## Deploy the sample
$(DEPLOY_CMD)
test: ## Run the sample smoke test
$(TEST_CMD)
run: $(DEPLOY_STEPS)
test-ci:
make $(DEPLOY_STEPS); return_code=`echo $$?`;\
make logs; make stop; exit $$return_code;
clean: ## Remove Terraform state
rm -rf .terraform
.PHONY: usage start stop logs install init deploy test run test-ci clean