Lint Terraform modules for provider mistakes and policy violations with TFLint
Check Terraform before plan or apply so invalid attributes, provider-specific mistakes, and custom rule violations are caught early.
Prerequisites
TFLint binary, Terraform configuration, optional plugin rules
Installation
Use the upstream install or setup path that matches your environment:
- brew install terraform-linters/tap/tflint
- docker run --rm -v $(pwd):/data -t ghcr.io/terraform-linters/tflint
- docker run --rm -v $(pwd):/data -t --entrypoint /bin/sh ghcr.io/terraform-linters/tflint -c "tflint --init && tflint"
Requirements and caveats from upstream:
Docker
- Instead of installing directly, you can use the Docker image:
- To download plugins, you can override the entrypoint to a shell (sh) to run --init and the main command in a single docker run command:
Basic usage or getting-started notes:
Download the appropriate archive from the latest release, verify it, and install the binary:
console
curl -sSLO https://github.com/terraform-linters/tflint/releases/latest/download/tflint_linux_amd64.zip
Extracted from upstream docs: https://raw.githubusercontent.com/terraform-linters/tflint/HEAD/README.md