Skip to content

Commit

Permalink
Refactored build config
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Nov 28, 2023
1 parent ceec735 commit 4f20329
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
TERRAFORM_VERSION=1.1.8
TF_PLUGIN_CACHE_DIR?=~/.terraform.d/plugin-cache/
TERRAFORM_VERSION=1.6.1
TF_PLUGIN_CACHE_DIR?=${HOME}/.terraform.d/plugin-cache/
AWS_DEFAULT_REGION?=ap-southeast-2

ifneq (, $(shell which terraform))
TERRAFORM=TF_PLUGIN_CACHE_DIR=$(TF_PLUGIN_CACHE_DIR) terraform
else
TERRAFORM=docker run --rm -v "${PWD}:/work" -v "$(TF_PLUGIN_CACHE_DIR):/plugin-cache" \
-e AWS_DEFAULT_REGION=$(AWS_DEFAULT_REGION) -e http_proxy=$(http_proxy) -e TF_PLUGIN_CACHE_DIR=/plugin-cache \
--net=host -w /work hashicorp/terraform:$(TERRAFORM_VERSION)
-e AWS_DEFAULT_REGION=$(AWS_DEFAULT_REGION) -e http_proxy=$(http_proxy) \
--net=host figurate/terraform:$(TERRAFORM_VERSION)
endif

TERRAFORM_DOCS=docker run --rm -v "${PWD}:/work" tmknom/terraform-docs
Expand Down
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ clean:
rm -rf .terraform/

validate:
$(TERRAFORM) init -upgrade && $(TERRAFORM) validate && \
$(TERRAFORM) -chdir=modules/terraform-lock init -upgrade && $(TERRAFORM) -chdir=modules/terraform-lock validate && \
$(TERRAFORM) -chdir=modules/single-table init -upgrade && $(TERRAFORM) -chdir=modules/single-table validate
$(TERRAFORM) init && $(TERRAFORM) validate

test: validate
$(CHECKOV) -d /work
Expand All @@ -29,12 +27,10 @@ docs: diagram
$(TERRAFORM_DOCS) markdown ./modules/single-table >./modules/single-table/README.md

format:
$(TERRAFORM) fmt -list=true ./ && \
$(TERRAFORM) fmt -list=true ./modules/terraform-lock && \
$(TERRAFORM) fmt -list=true ./modules/single-table
$(TERRAFORM) fmt -list=true -recursive

example:
$(TERRAFORM) -chdir=examples/$(EXAMPLE) init -upgrade && $(TERRAFORM) -chdir=examples/$(EXAMPLE) plan -input=false
$(TERRAFORM) -chdir=examples/$(EXAMPLE) init && $(TERRAFORM) -chdir=examples/$(EXAMPLE) plan -input=false

release: test
git tag $(VERSION) && git push --tags

0 comments on commit 4f20329

Please sign in to comment.