-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Support for Terraform Lint Checking (#34)
- Loading branch information
Showing
3 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ install: | |
script: | ||
- "make bash:lint" | ||
- "make make:lint" | ||
- "make terraform:install" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
TMP ?= /tmp | ||
TERRAFORM ?= $(BUILD_HARNESS_PATH)/terraform | ||
TERRAFORM_VERSION ?= 0.10.7 | ||
TERRAFORM_URL ?= https://releases.hashicorp.com/terraform/$(TERRAFORM_VERSION)/terraform_$(TERRAFORM_VERSION)_$(OS)_amd64.zip | ||
|
||
## Install terraform | ||
terraform\:install: | ||
@[ -x $(TERRAFORM) ] || ( \ | ||
echo "Installing Terraform $(TERRAFORM_VERSION) ($(OS)) from $(TERRAFORM_URL)" && \ | ||
curl '-#' -fL -o $(TMP)/terraform.zip $(TERRAFORM_URL) && \ | ||
unzip -q -d $(TMP)/ $(TMP)/terraform.zip && \ | ||
mv $(TMP)/terraform $(TERRAFORM) && \ | ||
rm -f $(TMP)/terraform.zip \ | ||
) | ||
$(TERRAFORM) version | ||
|
||
## Ensure all plugins can be fetched | ||
terraform\:get-plugins: | ||
@$(TERRAFORM) init -get-plugins -backend=false -input=false >/dev/null | ||
|
||
## Ensure all modules can be fetched | ||
terraform\:get-modules: | ||
@$(TERRAFORM) init -get -backend=false -input=false >/dev/null | ||
|
||
## Basic terraform sanity check | ||
terraform\:validate: | ||
@$(TERRAFORM) validate -check-variables=false | ||
|
||
## Lint check Terraform | ||
terraform\:lint: | ||
@FAIL=`$(TERRAFORM) fmt -write=false | xargs --no-run-if-empty -n 1 printf '\t- %s\n'`; \ | ||
[ -z "$$FAIL" ] || (echo "Terraform configuration needs linting. Run '$(TERRAFORM) fmt'"; echo $$FAIL; exit 1) |