forked from voyagegroup/tf_aws_ecs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
40 lines (30 loc) · 1.17 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
OS_TYPE = $(shell echo $(shell uname) | tr A-Z a-z)
OS_ARCH := amd64
TERRAFORM := ./terraform
TERRAFORM_VERSION := 0.11.7
TERRAFORM_URL = https://releases.hashicorp.com/terraform/$(TERRAFORM_VERSION)/terraform_$(TERRAFORM_VERSION)_$(OS_TYPE)_$(OS_ARCH).zip
EXCLUDES_DIRS := _test _example .terraform
MODULE_DIRS = $(shell find . -type f -name "*.tf" | xargs -I {} dirname {} | grep -v $(foreach _d, $(EXCLUDES_DIRS), -e $(_d)) | uniq | sort)
.PHONY: help all deps clean validate $(MODULE_DIRS)
.DEFAULT_GOAL := help
help:
@more Makefile
all: deps validate
deps: $(TERRAFORM)
$(TERRAFORM) version
clean:
@/bin/rm -f $(TERRAFORM)
@$(foreach _d, $(MODULE_DIRS), find $(_d) -type f -name "fixture_*.tf" -delete;)
$(TERRAFORM):
curl -L -fsS --retry 2 -o [email protected] $(TERRAFORM_URL)
unzip [email protected] && rm -f [email protected]
@chmod +x $@
$(MODULE_DIRS):
/bin/cp -af _test/tf_fixtures/fixture_*.tf $@/
$(TERRAFORM) init -input=false -get-plugins=true $@
validate: $(TERRAFORM) $(MODULE_DIRS)
@echo "[Validate to terraform modules]"
@for tf_dir in $(MODULE_DIRS); do \
printf "%-33s ... " "$$tf_dir"; \
$(TERRAFORM) $(@F) $$tf_dir && echo "OK" || IF_ERROR=1; \
done; exit $$IF_ERROR