Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tasks/modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,21 @@ endef

define plan_terraform_module
echo && echo "Planning $(1) ...";
$(TERRAFORM) -chdir=$(1) plan -input=false -out=terraform.tfplan -var-file $(VAR_FILE);
if [ -f "$(1)/$(VAR_FILE)" ]; then \
echo "Using $(VAR_FILE) for variable inputs"; \
$(TERRAFORM) -chdir=$(1) plan -input=false -out=terraform.tfplan -var-file $(VAR_FILE); \
else \
echo "$(VAR_FILE) doesn't exist, falling back to default (terraform.tfvars)"; \
$(TERRAFORM) -chdir=$(1) plan -input=false -out=terraform.tfplan; \
fi;
echo && echo "Creating JSON plan output for $(1) ...";
cd $(1) && $(TERRAFORM) show -json ./terraform.tfplan > ./terraform.tfplan.json;

endef

define tflint_terraform_module
echo && echo "Linting $(1) ...";
(cd $(1) && TF_LOG=info $(TFLINT) -c $(TFLINT_CONFIG) || TF_LOG=info $(TFLINT) -c ../../$(TFLINT_CONFIG)) || exit 1;
(cd $(1) && TF_LOG=info $(TFLINT) -c $(PWD)/$(TFLINT_CONFIG)) || exit 1;

endef

Expand Down