All Projects → terraform-linters → Tflint

terraform-linters / Tflint

Licence: mpl-2.0
A Pluggable Terraform Linter

Programming Languages

go
31211 projects - #10 most used programming language
HCL
1544 projects

Projects that are alternatives of or similar to Tflint

Terraform Provider Snowflake
Terraform provider for managing Snowflake accounts
Stars: ✭ 165 (-94.01%)
Mutual labels:  terraform
Awesome Terraform
Curated list of resources on HashiCorp's Terraform
Stars: ✭ 2,618 (-5.01%)
Mutual labels:  terraform
Terraform Provider Sentry
Terraform provider for Sentry
Stars: ✭ 183 (-93.36%)
Mutual labels:  terraform
Terraform Aws Components
Opinionated, self-contained Terraform root modules that each solve one, specific problem
Stars: ✭ 168 (-93.9%)
Mutual labels:  terraform
Homebrew Terraforms
Homebrew repository for a Terraform version switcher and all Terraform versions
Stars: ✭ 174 (-93.69%)
Mutual labels:  terraform
Tf aws bastion s3 keys
A Terraform module for creating bastion host on AWS EC2 and populate its ~/.ssh/authorized_keys with public keys from bucket
Stars: ✭ 178 (-93.54%)
Mutual labels:  terraform
Terraform Aws Cloudfront S3 Cdn
Terraform module to easily provision CloudFront CDN backed by an S3 origin
Stars: ✭ 162 (-94.12%)
Mutual labels:  terraform
Terraform Visual
Terraform Visual is an interactive way of visualizing your Terraform plan
Stars: ✭ 190 (-93.11%)
Mutual labels:  terraform
K8s Scw Baremetal
Kubernetes installer for Scaleway bare-metal AMD64 and ARMv7
Stars: ✭ 176 (-93.61%)
Mutual labels:  terraform
Fogg
Manage Infrastructure as Code with less pain.
Stars: ✭ 181 (-93.43%)
Mutual labels:  terraform
Tfk8s
A tool for converting Kubernetes YAML manifests to Terraform HCL
Stars: ✭ 167 (-93.94%)
Mutual labels:  terraform
Terraform Provider Vultr
Terraform Vultr Provider
Stars: ✭ 172 (-93.76%)
Mutual labels:  terraform
Terraform Provider Azuread
Terraform provider for Azure Active Directory
Stars: ✭ 178 (-93.54%)
Mutual labels:  terraform
Terraform Aws Cloudtrail Cloudwatch Alarms
Terraform module for creating alarms for tracking important changes and occurrences from cloudtrail.
Stars: ✭ 170 (-93.83%)
Mutual labels:  terraform
Stubbornjava
Unconventional Java code for building web servers / services without a framework. Think dropwizard but as a seed project instead of a framework. If this project had a theme it would be break the rules but be mindful of your decisions.
Stars: ✭ 184 (-93.32%)
Mutual labels:  terraform
Terraform Provider Lxd
LXD Resource provider for Terraform
Stars: ✭ 164 (-94.05%)
Mutual labels:  terraform
Terraform Provider Kubectl
Terraform provider to handle raw kubernetes manifest yaml files
Stars: ✭ 174 (-93.69%)
Mutual labels:  terraform
Laravel Deployment
📗[WIP] 追求质量的 Laravel 应用部署上线课程。
Stars: ✭ 190 (-93.11%)
Mutual labels:  terraform
Infra
Infrastructure to set up the public Compiler Explorer instances and compilers
Stars: ✭ 184 (-93.32%)
Mutual labels:  terraform
Tfenv
Terraform version manager
Stars: ✭ 2,804 (+1.74%)
Mutual labels:  terraform

TFLint

Build Status GitHub release Terraform Compatibility License: MPL 2.0 Go Report Card Homebrew

A Pluggable Terraform Linter

Features

TFLint is a framework and each feature is provided by plugins, the key features are as follows:

  • Find possible errors (like illegal instance types) for Major Cloud providers (AWS/Azure/GCP).
  • Warn about deprecated syntax, unused declarations.
  • Enforce best practices, naming conventions.

Installation

Bash script (Linux):

curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash

Homebrew (macOS):

brew install tflint

Chocolatey (Windows):

choco install tflint

Docker

Instead of installing directly, you can use the Docker images:

Name Description
ghcr.io/terraform-linters/tflint Basic image
ghcr.io/terraform-linters/tflint-bundle A Docker image with TFLint and ruleset plugins

Example:

docker run --rm -v $(pwd):/data -t ghcr.io/terraform-linters/tflint

GitHub Actions

If you want to run on GitHub Actions, setup-tflint action is available.

Getting Started

If you are using an AWS/Azure/GCP provider, it is a good idea to install the plugin and try it according to each usage:

Rules for the Terraform Language is built into the TFLint binary, so you don't need to install any plugins. Please see Rules for a list of available rules.

If you want to extend TFLint with other plugins, you can declare the plugins in the config file and easily install them with tflint --init.

plugin "foo" {
  enabled = true
  version = "0.1.0"
  source  = "github.com/org/tflint-ruleset-foo"

  signing_key = <<-KEY
  -----BEGIN PGP PUBLIC KEY BLOCK-----

  mQINBFzpPOMBEADOat4P4z0jvXaYdhfy+UcGivb2XYgGSPQycTgeW1YuGLYdfrwz
  9okJj9pMMWgt/HpW8WrJOLv7fGecFT3eIVGDOzyT8j2GIRJdXjv8ZbZIn1Q+1V72
  AkqlyThflWOZf8GFrOw+UAR1OASzR00EDxC9BqWtW5YZYfwFUQnmhxU+9Cd92e6i
  ...
  KEY
}

See also Configuring Plugins.

Usage

TFLint inspects files under the current directory by default. You can change the behavior with the following options/arguments:

$ tflint --help
Usage:
  tflint [OPTIONS] [FILE or DIR...]

Application Options:
  -v, --version                                                 Print TFLint version
      --init                                                    Install plugins
      --langserver                                              Start language server
  -f, --format=[default|json|checkstyle|junit|compact|sarif]    Output format (default: default)
  -c, --config=FILE                                             Config file name (default: .tflint.hcl)
      --ignore-module=SOURCE                                    Ignore module sources
      --enable-rule=RULE_NAME                                   Enable rules from the command line
      --disable-rule=RULE_NAME                                  Disable rules from the command line
      --only=RULE_NAME                                          Enable only this rule, disabling all other defaults. Can be specified multiple times
      --enable-plugin=PLUGIN_NAME                               Enable plugins from the command line
      --var-file=FILE                                           Terraform variable file name
      --var='foo=bar'                                           Set a Terraform variable
      --module                                                  Inspect modules
      --force                                                   Return zero exit status even if issues found
      --no-color                                                Disable colorized output
      --loglevel=[trace|debug|info|warn|error]                  Change the loglevel

Help Options:
  -h, --help                                                    Show this help message

See User Guide for details.

FAQ

Does TFLint check modules recursively?

No. TFLint always checks only the current root module (no recursive check). However, you can check calling child modules based on module arguments by enabling Module Inspection. This allows you to check that you are not passing illegal values to the module.

Note that if you want to recursively inspect local modules, you need to run them in each directory. This is a limitation that occurs because Terraform always works for one directory. TFLint tries to emulate Terraform's semantics, so cannot perform recursive inspection.

Do I need to install Terraform for TFLint to work?

No. TFLint works as a single binary because Terraform is embedded as a library. Note that this means that the version of Terraform used is determined for each TFLint version. See also Compatibility with Terraform.

TFLint reports a loading error in my code, but this is valid in Terraform. Why?

First, check the version of Terraform and TFLint you are using. TFLint loads files differently than the installed Terraform, so an error can occur if the version of Terraform supported by TFLint is different from the installed Terraform.

Debugging

If you don't get the expected behavior, you can see the detailed logs when running with TFLINT_LOG environment variable.

$ TFLINT_LOG=debug tflint

Developing

See Developer Guide.

Stargazers over time

Stargazers over time

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].