Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise rules documentation #158

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ All rules are enabled by default, but by setting `preset = "recommended"`, you c
|[terraform_typed_variables](terraform_typed_variables.md)|Disallow `variable` declarations without type|✔|
|[terraform_unused_declarations](terraform_unused_declarations.md)|Disallow variables, data sources, and locals that are declared but never used|✔|
|[terraform_unused_required_providers](terraform_unused_required_providers.md)|Check that all `required_providers` are used in the module||
|[terraform_workspace_remote](terraform_workspace_remote.md)|`terraform.workspace` should not be used with a "remote" backend with remote execution|✔|
|[terraform_workspace_remote](terraform_workspace_remote.md)|`terraform.workspace` should not be used with a "remote" backend with remote execution in Terraform v1.0.x|✔|
2 changes: 1 addition & 1 deletion docs/rules/terraform_comment_syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0

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.

* [Configuration Syntax: Comments](https://www.terraform.io/docs/configuration/syntax.html#comments)
* [Configuration Syntax: Comments](https://developer.hashicorp.com/terraform/language/syntax/configuration#comments)

## How To Fix

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/terraform_deprecated_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0

## Why

Terraform v0.12 supports traditional square brackets for accessing list items by index or using the splat operator (`*`). However, for backward compatibility 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.
Terraform supports traditional square brackets for accessing list items by index or using the splat operator (`*`). However, for backward compatibility, 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.

* [Legacy Splat Expressions](https://developer.hashicorp.com/terraform/language/expressions/splat#legacy-attribute-only-splat-expressions)

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/terraform_deprecated_interpolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0

Terraform v0.12 introduces a new interpolation syntax, but continues to support the old 0.11-style interpolation syntax for compatibility.

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.
`terraform fmt` can replace this redundant interpolation, so although it is not deprecated in the latest Terraform version, this rule allows you to issue a warning similar to Terraform v0.12.14.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation warning ended up not being an error and was removed in v0.15 hashicorp/terraform#27835


## How To Fix

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/terraform_documented_outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0

## Why

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/terraform-docs/terraform-docs).

## How To Fix

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/terraform_documented_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0

## Why

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/terraform-docs/terraform-docs).

## How To Fix

Expand Down
8 changes: 4 additions & 4 deletions docs/rules/terraform_module_version.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# terraform_module_version

Ensure that all modules sourced from a [Terraform Registry](https://www.terraform.io/docs/language/modules/sources.html#terraform-registry) specify a `version`.
Ensure that all modules sourced from a [Terraform Registry](https://developer.hashicorp.com/terraform/language/modules/sources#terraform-registry) specify a `version`.

> This rule is enabled by "recommended" preset.

Expand Down Expand Up @@ -82,17 +82,17 @@ Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/v0.1.0/

## Why

Terraform's [module version documentation](https://www.terraform.io/docs/language/modules/syntax.html#version) states:
Terraform's [module version documentation](https://developer.hashicorp.com/terraform/language/modules/syntax#version) states:

> When using modules installed from a module registry, we recommend explicitly constraining the acceptable version numbers to avoid unexpected or unwanted changes.

When no `version` is specified, Terraform will download the latest version available on the registry. Using a new major version of a module could cause the destruction of existing resources, or the creation of new resources that are not backwards compatible. Generally you should at least constrain modules to a specific major version.

### Exact Versions

Depending on your workflow, you may want to enforce that modules specify an _exact_ version by settings `exact = true` for this rule. This will disallow any module that includes multiple comma-separated version constraints, or any [constraint operator](https://www.terraform.io/docs/language/expressions/version-constraints.html#version-constraint-syntax) other than `=`. Exact versions are often used with automated dependency managers like [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates) and [Renovate](https://docs.renovatebot.com), which will automatically propose a pull request to update the module when a new version is released.
Depending on your workflow, you may want to enforce that modules specify an _exact_ version by settings `exact = true` for this rule. This will disallow any module that includes multiple comma-separated version constraints, or any [constraint operator](https://developer.hashicorp.com/terraform/language/expressions/version-constraints#version-constraint-syntax) other than `=`. Exact versions are often used with automated dependency managers like [Dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates) and [Renovate](https://docs.renovatebot.com), which will automatically propose a pull request to update the module when a new version is released.

Keep in mind that the module may include further child modules, which have their own version constraints. TFLint _does not_ check version constraints set in child modules. **Enabling this rule cannot guarantee that `terraform init` will be deterministic**. Use [Terraform dependency lock files](https://www.terraform.io/docs/language/dependency-lock.html) to ensure that Terraform will always use the same version of all modules (and providers) until you explicitly update them.
Keep in mind that the module may include further child modules, which have their own version constraints. TFLint _does not_ check version constraints set in child modules. **Enabling this rule cannot guarantee that `terraform init` will be deterministic**. Use [Terraform dependency lock files](https://developer.hashicorp.com/terraform/language/files/dependency-lock) to ensure that Terraform will always use the same version of all modules (and providers) until you explicitly update them.

## How To Fix

Expand Down
4 changes: 2 additions & 2 deletions docs/rules/terraform_naming_convention.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0

## Why

Naming conventions are optional, so it is not necessary to follow this.
But this rule is useful if you want to force the following naming conventions in line with the [Terraform Plugin Naming Best Practices](https://www.terraform.io/docs/extend/best-practices/naming.html).
Naming conventions are optional, so you don't necessarily have to follow them.
However, if your team owns Terraform configurations, it can be helpful to have a consistent naming convention.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linked documentation doesn't specifically mention naming conventions for label names, so deleted it.


## How To Fix

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/terraform_required_providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ terraform {
}
```

Provider version constraints can be specified using a [version argument within a provider block](https://www.terraform.io/docs/configuration/providers.html#provider-versions) for backwards compatibility. This approach is now discouraged, particularly for child modules.
Provider version constraints can be specified using a [version argument within a provider block](https://developer.hashicorp.com/terraform/language/providers/configuration#provider-versions) for backwards compatibility. This approach is now discouraged, particularly for child modules.

Optionally, you can disable enforcement of either `source` or `version` by setting the corresponding attribute in the rule configuration to `false`.
4 changes: 2 additions & 2 deletions docs/rules/terraform_standard_module_structure.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# terraform_standard_module_structure

Ensure that a module complies with the Terraform [Standard Module Structure](https://www.terraform.io/docs/modules/index.html#standard-module-structure)
Ensure that a module complies with the Terraform [Standard Module Structure](https://developer.hashicorp.com/terraform/language/modules/develop/structure)

## Example

Expand All @@ -23,7 +23,7 @@ Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0

## Why

Terraform's documentation outlines a [Standard Module Structure](https://www.terraform.io/docs/modules/structure.html). A minimal module should have a `main.tf`, `variables.tf`, and `outputs.tf` file. Variable and output blocks should be included in the corresponding file.
Terraform's documentation outlines a [Standard Module Structure](https://developer.hashicorp.com/terraform/language/modules/develop/structure). A minimal module should have a `main.tf`, `variables.tf`, and `outputs.tf` file. Variable and output blocks should be included in the corresponding file.

## How To Fix

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/terraform_typed_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0
Since `type` is optional value, it is not always necessary to declare it. But this rule is useful if you want to force declaration of a type.

## How To Fix
Add a type to the variable. See https://www.terraform.io/docs/configuration/variables.html#type-constraints for more details about types
Add a type to the variable. See https://developer.hashicorp.com/terraform/language/values/variables#type-constraints for more details about types
2 changes: 2 additions & 0 deletions docs/rules/terraform_unused_required_providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Check that all `required_providers` are used in the module.

Note: Because TFLint cannot traverse the complete module tree, it may issue warnings for `required_providers` declared to specify constraints on the provider versions used by a module. If this false positive is unacceptable, you can disable the rule. See also https://github.com/terraform-linters/tflint-ruleset-terraform/issues/21.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It mentions the technical limitations that pose a problem in enabling this rule.


## Configuration

```hcl
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/terraform_workspace_remote.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`terraform.workspace` should not be used with a "remote" backend with remote execution in Terraform v1.0.x.

If remote operations are [disabled](https://www.terraform.io/docs/cloud/run/index.html#disabling-remote-operations) for your workspace, you can safely disable this rule:
If remote operations are [disabled](https://developer.hashicorp.com/terraform/cloud-docs/run/remote-operations#disabling-remote-operations) for your workspace, you can safely disable this rule:

```hcl
rule "terraform_workspace_remote" {
Expand Down