Skip to content

Instantly share code, notes, and snippets.

@kevinkarwaski
Last active September 18, 2020 00:41
Show Gist options
  • Save kevinkarwaski/a57fd43f36c0e0eb4deb06d05b887545 to your computer and use it in GitHub Desktop.
Save kevinkarwaski/a57fd43f36c0e0eb4deb06d05b887545 to your computer and use it in GitHub Desktop.
name: Lint and Validate Terraform Code
on:
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
env:
AWS_DEFAULT_REGION: us-east-1
steps:
- uses: actions/checkout@v1
- name: Install Terraform and Terragrunt
run: |
brew tap rocketinsights/tgenv
brew install tfenv tgenv
tfenv install
tgenv install
- name: Get Versions
run: |
terragrunt --version
terraform --version
- name: Terraform Init
run: find . -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (cd "$m" && terraform init -input=false -backend=false) || exit 1; done
- name: Validate Terraform configs
run: find . -name ".terraform" -prune -o -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (cd "$m" && terraform validate && echo "√ $m") || exit 1 ; done
- name: Check Terraform config formatting
run: terraform fmt -write=false -recursive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment