Last active
March 26, 2020 14:34
-
-
Save masutaka/ab96bf8baed8670f438916bd4cf95f0d to your computer and use it in GitHub Desktop.
Makefiles for terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
├── Makefile # (1) | |
└── terraform | |
├── aws | |
│ ├── Makefile # (2) | |
│ └── main.tf | |
└── heroku | |
├── Makefile # (3) | |
└── main.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAKE := make | |
TARGETS := aws heroku | |
define make-r | |
@for i in $(TARGETS); do \ | |
$(MAKE) -w -C terraform/$$i $(1) || exit $$?; \ | |
done | |
endef | |
# Recursive terraform init | |
.PHONY: init-r | |
init-r: | |
$(call make-r, init) | |
# Recursive terraform plan | |
.PHONY: plan-r | |
plan-r: | |
$(call make-r, plan) | |
# Recursive terraform apply | |
.PHONY: apply-r | |
apply-r: | |
$(call make-r, apply) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TERRAFORM := terraform | |
.PHONY: init | |
init: | |
$(TERRAFORM) init | |
.PHONY: plan | |
plan: | |
$(TERRAFORM) plan | |
.PHONY: apply | |
apply: | |
$(TERRAFORM) apply |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TERRAFORM := terraform | |
.PHONY: init | |
init: | |
$(TERRAFORM) init | |
.PHONY: plan | |
plan: | |
$(TERRAFORM) plan | |
.PHONY: apply | |
apply: | |
$(TERRAFORM) apply |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment