You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a template repository for building a custom ruleset. You can create a plugin repository from "Use this template". See also [Writing Plugins](https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/plugins.md).
6
+
TFLint ruleset plugin for Terraform Language
7
+
8
+
This ruleset focus on possible errors and best practices about Terraform Language.
5
9
6
10
## Requirements
7
11
8
-
- TFLint v0.35+
12
+
- TFLint v0.40+
9
13
- Go v1.18
10
14
11
15
## Installation
12
16
13
-
You can install the plugin with `tflint --init`. Declare a config in `.tflint.hcl` as follows:
17
+
This ruleset is built into TFLint, so you usually don't need to worry about how to install it. You can check the built-in version with `tflint -v`:
18
+
19
+
```
20
+
$ tflint -v
21
+
TFLint version 0.40.0
22
+
+ ruleset.terraform (0.1.0-bundled)
23
+
```
24
+
25
+
If you want to use a version different from the built-in version, you can declare `plugin` in `.tflint.hcl` as follows and install it with `tflint --init`:
Terraform language rules implement recommendations from the [Terraform language documentation](https://www.terraform.io/language). If you want to enforce additional usage and style conventions in your configuration, you can author your own ruleset plugin.
4
+
5
+
Below is a list of available rules.
6
+
7
+
|Rule|Description|Enabled|
8
+
| --- | --- | --- |
9
+
|[terraform_comment_syntax](terraform_comment_syntax.md)|Disallow `//` comments in favor of `#`||
10
+
|[terraform_deprecated_index](terraform_deprecated_index.md)|Disallow legacy dot index syntax||
|[terraform_documented_outputs](terraform_documented_outputs.md)|Disallow `output` declarations without description||
13
+
|[terraform_documented_variables](terraform_documented_variables.md)|Disallow `variable` declarations without description||
14
+
|[terraform_empty_list_equality](terraform_empty_list_equality.md)|Disallow comparisons with `[]` when checking if a collection is empty||
15
+
|[terraform_module_pinned_source](terraform_module_pinned_source.md)|Disallow specifying a git or mercurial repository as a module source without pinning to a version|✔|
16
+
|[terraform_module_version](terraform_module_version.md)|Checks that Terraform modules sourced from a registry specify a version|✔|
17
+
|[terraform_naming_convention](terraform_naming_convention.md)|Enforces naming conventions for resources, data sources, etc||
18
+
|[terraform_required_providers](terraform_required_providers.md)|Require that all providers have version constraints through required_providers||
19
+
|[terraform_required_version](terraform_required_version.md)|Disallow `terraform` declarations without require_version||
20
+
|[terraform_standard_module_structure](terraform_standard_module_structure.md)|Ensure that a module complies with the Terraform Standard Module Structure||
21
+
|[terraform_typed_variables](terraform_typed_variables.md)|Disallow `variable` declarations without type||
22
+
|[terraform_unused_declarations](terraform_unused_declarations.md)|Disallow variables, data sources, and locals that are declared but never used||
23
+
|[terraform_unused_required_providers](terraform_unused_required_providers.md)|Check that all `required_providers` are used in the module||
24
+
|[terraform_workspace_remote](terraform_workspace_remote.md)|`terraform.workspace` should not be used with a "remote" backend with remote execution|✔|
The Terraform language supports two different syntaxes for single-line comments: `#` and `//`. However, `#` is the default comment style and should be used in most cases.
Terraform v0.12 supports traditional square brackets for accessing list items by index. However, for backward compatability with v0.11, Terraform continues to support accessing list items with the dot syntax normally used for attributes. While Terraform does not print warnings for this syntax, it is no longer documented and its use is discouraged.
29
+
30
+
## How To Fix
31
+
32
+
Switch to the square bracket syntax when accessing items in list, including resources that use `count`.
Terraform v0.12 introduces a new interpolation syntax, but continues to support the old 0.11-style interpolation syntax for compatibility.
33
+
34
+
Terraform will currently print diagnostic warnings when deprecated interpolations are used. Consistent with its deprecation policy, they will raise errors in the next major release (v0.13). TFLint emits an issue instead of a warning with the same logic.
35
+
36
+
## How To Fix
37
+
38
+
Switch to the new interpolation syntax. See the release notes for Terraform 0.12.14 for details: https://github.com/hashicorp/terraform/releases/tag/v0.12.14
Since `description` is optional value, it is not always necessary to write it. But this rule is useful if you want to force the writing of description. Especially it is useful when combined with [terraform-docs](https://github.com/segmentio/terraform-docs).
Since `description` is optional value, it is not always necessary to write it. But this rule is useful if you want to force the writing of description. Especially it is useful when combined with [terraform-docs](https://github.com/segmentio/terraform-docs).
The `==` operator can only return true when the two operands have identical types, and the type of `[]` alone (without any further type conversions) is an empty tuple rather than a list of objects, strings, numbers or any other type. Therefore, a comparison with a single `[]` with the goal of checking if a collection is empty, will always return false.
33
+
34
+
## How To Fix
35
+
36
+
Check if a collection is empty by checking its length instead. For example: `length(var.my_list) == 0`.
0 commit comments