Skip to content

Commit

Permalink
Add terraform_deprecated_lookup rule to the recommended preset
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Sep 30, 2023
1 parent 6afcb25 commit e6651cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ All rules are enabled by default, but by setting `preset = "recommended"`, you c
|[terraform_comment_syntax](terraform_comment_syntax.md)|Disallow `//` comments in favor of `#`||
|[terraform_deprecated_index](terraform_deprecated_index.md)|Disallow legacy dot index syntax||
|[terraform_deprecated_interpolation](terraform_deprecated_interpolation.md)|Disallow deprecated (0.11-style) interpolation||
|[terraform_deprecated_lookup](terraform_deprecated_lookup.md)|Disallow deprecated `lookup()` function with only 2 arguments.||
|[terraform_deprecated_lookup](terraform_deprecated_lookup.md)|Disallow deprecated `lookup()` function with only 2 arguments.||
|[terraform_documented_outputs](terraform_documented_outputs.md)|Disallow `output` declarations without description||
|[terraform_documented_variables](terraform_documented_variables.md)|Disallow `variable` declarations without description||
|[terraform_empty_list_equality](terraform_empty_list_equality.md)|Disallow comparisons with `[]` when checking if a collection is empty||
Expand Down
4 changes: 3 additions & 1 deletion docs/rules/terraform_deprecated_lookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Disallow deprecated [`lookup` function](https://developer.hashicorp.com/terraform/language/functions/lookup) usage without a default.

> This rule is enabled by "recommended" preset.
## Example

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

## Why

Calling [`lookup`](https://developer.hashicorp.com/terraform/language/functions/lookup) with 2 arguments has been deprecated since Terraform v0.7. `lookup(map, key)` is equivalent to the native index syntax `map[key]`. `lookup` should only be used with the third `default` argument, even though it is optional for backward compatiblity.
Calling [`lookup`](https://developer.hashicorp.com/terraform/language/functions/lookup) with 2 arguments has been deprecated since Terraform v0.7. `lookup(map, key)` is equivalent to the native index syntax `map[key]`. `lookup` should only be used with the third `default` argument, even though it is optional for backward compatibility.

## How To Fix

Expand Down
3 changes: 2 additions & 1 deletion rules/preset.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var PresetRules = map[string][]tflint.Rule{
NewTerraformCommentSyntaxRule(),
NewTerraformDeprecatedIndexRule(),
NewTerraformDeprecatedInterpolationRule(),
NewTerraformDeprecatedLookupRule(),
NewTerraformDocumentedOutputsRule(),
NewTerraformDocumentedVariablesRule(),
NewTerraformEmptyListEqualityRule(),
Expand All @@ -20,11 +21,11 @@ var PresetRules = map[string][]tflint.Rule{
NewTerraformUnusedDeclarationsRule(),
NewTerraformUnusedRequiredProvidersRule(),
NewTerraformWorkspaceRemoteRule(),
NewTerraformDeprecatedLookupRule(),
},
"recommended": {
NewTerraformDeprecatedIndexRule(),
NewTerraformDeprecatedInterpolationRule(),
NewTerraformDeprecatedLookupRule(),
NewTerraformEmptyListEqualityRule(),
NewTerraformModulePinnedSourceRule(),
NewTerraformModuleVersionRule(),
Expand Down

0 comments on commit e6651cc

Please sign in to comment.