Action — tflint
Lints a Terraform module with tflint: deprecated syntax, unused declarations and, with the plugins the module's .tflint.hcl declares, provider-specific mistakes. It is the tflint job of ci-terraform.yml.
Usage
yaml
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: KevinDeBenedetti/github-workflows/.github/actions/tflint@main
with:
tf-dir: terraformInputs
| Input | Default | Description |
|---|---|---|
tf-dir | terraform | Directory of the Terraform module (its .tflint.hcl is read from there) |
token | the job token | Token for tflint's plugin downloads from GitHub releases (lifts the API rate limit) |
Steps
- Install the pinned
tflintwithinstall-tool tflint --chdir=<tf-dir> --init: install the plugins.tflint.hcldeclarestflint --chdir=<tf-dir> --format=compact: one line per issue
Notes
- Without a
.tflint.hcl, tflint runs its bundled Terraform ruleset. - The step fails with tflint's exit code when it finds an issue. Set the lowest failing severity, or disable a rule, in
.tflint.hcl. - No
terraform initis needed: tflint reads the module's files, and calls local modules only. - The script is
tflint.sh; its tests are intests/tflint.bats.