-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
makefile
44 lines (31 loc) · 959 Bytes
/
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
.SECONDEXPANSION:
export TF_CLI_CONFIG_FILE := $(CURDIR)/.terraformrc
MODULES := $(wildcard modules/*)
MODULEMAKEFILES := $(foreach module,$(MODULES),$(module)/makefile)
MAKEMODULES := $(foreach module,$(MODULES),$(module)/default)
CLEANMODULES := $(foreach module,$(MODULES),$(module)/clean)
MODULESCOMMAND ?= default
.PHONY: default
default: modules
.PHONY: fmt
fmt:
terraform fmt -recursive
.PHONY: modules
modules: makefiles makemodules
.PHONY: makefiles
makefiles: $(MODULEMAKEFILES)
$(MODULEMAKEFILES): %/makefile: makefiles/terraform.mk
cp "$<" "$@"
.PHONY: makemodules
makemodules: $(MAKEMODULES)
$(MAKEMODULES): %/default: .terraformrc
$(MAKE) -C "$*" "$(MODULESCOMMAND)"
$(CLEANMODULES): %/clean:
$(MAKE) -C "$*" clean
.PHONY: clean
clean: $(CLEANMODULES)
all/%:
$(MAKE) modules MODULESCOMMAND=$(*)
.terraformrc:
mkdir -p .terraform-plugins
echo 'plugin_cache_dir = "$(CURDIR)/.terraform-plugins"' > .terraformrc