Skip to content

Instantly share code, notes, and snippets.

@OlegGorj
Created March 7, 2018 22:52
Show Gist options
  • Save OlegGorj/1726782200247f519df3b557b6f906ed to your computer and use it in GitHub Desktop.
Save OlegGorj/1726782200247f519df3b557b6f906ed to your computer and use it in GitHub Desktop.
Terraform validates with Travis CI
language: bash
sudo: required
env:
- tf_version=0.11.3
before_install:
- wget https://releases.hashicorp.com/terraform/${tf_version}/terraform_${tf_version}_linux_amd64.zip -O /tmp/terraform.zip
- sudo unzip -d /usr/local/bin/ /tmp/terraform.zip
script:
- make test
- make fmt
modules = $(shell find . -type f -name "*.tf" -exec dirname {} \;|sort -u)
.PHONY: test
default: test
test:
@for m in $(modules); do (terraform validate "$$m" && echo "√ $$m") || exit 1 ; done
fmt:
@if [ `terraform fmt | wc -c` -ne 0 ]; then echo "terraform files need be formatted"; exit 1; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment