Skip to content

Warning

You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

GitHub Action linting Terraform files

Actions
GitHub Action that will run TFlint on Terraform files
0.2
Star (16)

GitHub Action linting Terraform files

GitHub Action that will run TFlint on Terraform files.

Dockerized as devopsinfra/action-tflint.

Container is a stripped down image of my other creation - devops-infra/docker-terragrunt - framework for managing Infrastructure-as-a-Code.

So it's main use will be everywhere where Terraform is used and is great for statically or actively checking modules' sources.

Main action is using wata727's TFLint.

Badge swag

Master branch Other branches
GitHub repo GitHub code size in bytes GitHub last commit GitHub license
DockerHub Docker version Image size Docker Pulls

Reference

    - name: Run the Action
      uses: devops-infra/action-tflint@master
      with:
        dir_filter: modules
Input Variable Required Default Description
dir_filter No * Prefixes or sub-directories to search for Terraform modules. Use comma as separator.
fail_on_changes No true Whether TFLint should fail whole action.
tflint_config No .tflint.hcl Location from repository root to TFLint config file. Disables tflint_params.
tflint_params No `` Parameters passed to TFLint binary. See TFLint for details.
run_init No true Whether the action should run terraform init. Defaults to true.

Examples

By default fail if lint errors found in any subdirectory. Run the Action via GitHub.

name: Check TFLint
on:
  push:
    branches:
      - "**"
jobs:
  format-hcl:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Check linting of Terraform files
      uses: devops-infra/action-tflint@master

Use different location for TFLint config file and parse only aws* and gcp* modules in modules/ directory. Run the Action via GitHub.

name: Check TFLint with custom config
on:
  push:
    branches:
      - "**"
jobs:
  format-hcl:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Check linting of Terraform modules
      uses: devops-infra/action-tflint@master
      with:
        tflint_config: modules/.tflint.hcl
        dir_filter: modules/aws,modules/gcp

Use deep check (need cloud credentials) and treat all directories under modules as Terraform modules. Run the Action via DockerHub.

name: Check TFLint with custom config
on:
  push:
    branches:
      - "**"
jobs:
  format-hcl:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Check linting of Terraform modules
      uses: devops-infra/action-tflint@master
      with:
        tflint_params: "--module --deep"
        dir_filter: modules

GitHub Action linting Terraform files is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

GitHub Action that will run TFlint on Terraform files
0.2

GitHub Action linting Terraform files is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.