Member-only story
TFLint & How to Lint Your Terraform Code!
In this article, we will look into ‘linting’, explaining what it is and why you should ‘lint’, before looking at the popular open-source Terraform Linter, TFLint.
What is TFLint?
TFLint is a popular open-source linter and static analysis tool designed explicitly for Terraform. It performs automated checks on Terraform configurations to identify potential issues, errors, and violations of best practices. TFLint helps maintain code quality, consistency, and reliability in Terraform projects.
Even though they are mainly static code analysis tools, Other open-source tools like Checkov (that can incidentally also be used with AWS Cloudformation and Kubernetes), and Terrascan can be used for Terraform linting.
Terraform also includes an in-built command terraform fmt
formatting tool that helps enforce consistent code style across Terraform configurations. It automatically adjusts the formatting of your code to adhere to the Terraform style conventions, ensuring clean and readable code.
It is not strictly a linter, as its primary function is to format the code, and it doesn’t offer the same level of analysis and rule enforcement that dedicated linters provide.
Another built-in command terraform validate
only validates the syntax of your…