-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
55 lines (39 loc) · 1.23 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
51
52
53
54
55
.SECONDEXPANSION:
export TF_CLI_CONFIG_FILE := $(CURDIR)/.terraformrc
MODULES := $(foreach main,$(wildcard */*/main.tf),$(subst /main.tf,,$(main)))
MODULEMAKEFILES := $(foreach module,$(MODULES),$(module)/makefile)
MAKEMODULES := $(foreach module,$(MODULES),$(module)/default)
CLEANMODULES := $(foreach module,$(MODULES),$(module)/clean)
.PHONY: default
default: layers modules
.PHONY: fmt
fmt:
terraform fmt -recursive
.PHONY: layers
layers: \
elasticache-redis/auth-token/rotation/redis.zip \
rds-postgres/admin-login/rotation/postgres.zip
.PHONY: modules
modules: makefiles makemodules
.PHONY: makefiles
makefiles: $(MODULEMAKEFILES)
$(MODULEMAKEFILES): %/makefile: makefiles/terraform.mk
cp "$<" "$@"
.PHONY: makemodules
makemodules: $(MAKEMODULES)
$(MAKEMODULES): %/default: .terraformrc
$(MAKE) -C "$*"
$(CLEANMODULES): %/clean:
$(MAKE) -C "$*" clean
.PHONY: clean
clean: $(CLEANMODULES)
rm -rf .terraform-plugins .terraformrc tmp
.terraformrc:
mkdir -p .terraform-plugins
echo 'plugin_cache_dir = "$(CURDIR)/.terraform-plugins"' > .terraformrc
%/postgres.zip: layers/postgres/package.zip
cp "$<" "$@"
%/redis.zip: layers/redis/package.zip
cp "$<" "$@"
layers/%/package.zip: layers/%/*
$(MAKE) -C layers/"$*"