terraform-linters / tflint

A Pluggable Terraform Linter
Mozilla Public License 2.0
4.86k stars 354 forks source link

Rule not found: aws_instance_previous_type (v0.24.0) #1054

Closed suzuki-shunsuke closed 3 years ago

suzuki-shunsuke commented 3 years ago

When I upgrade tflint from v0.23.1 to v0.24.0, an error about aws_instance_previous_type occurs.

main.tf

resource "aws_instance" "foo" {
  instance_type = "m3.medium"
}

provider "aws" {
  version = "~> 3.26.0"
  region  = "ap-northeast-1"
}

terraform {
  required_version = ">= 0.13"
  required_providers {
    aws = {
      source = "hashicorp/aws"
    }
  }
}

.tflint.hcl

rule "aws_instance_previous_type" {
  enabled = false
}
$ tflint
Failed to check rule config. An error occurred:

Error: Rule not found: aws_instance_previous_type

But if I remove the above configuration about aws_instance_previous_type, it seems that aws_instance_previous_type works.

# rule "aws_instance_previous_type" {
#   enabled = false
# }
$ tflint
1 issue(s) found:

Warning: "m3.medium" is previous generation instance type. (aws_instance_previous_type)

  on main.tf line 2:
   2:   instance_type = "m3.medium"

Reference: https://github.com/terraform-linters/tflint-ruleset-aws/blob/v0.2.0/docs/rules/aws_instance_previous_type.md

This error doesn't occur when I use tflint v0.23.1.

$ tflint -v
TFLint version 0.23.1
+ ruleset.aws (0.1.2-bundled)

$ cat .tflint.hcl 
rule "aws_instance_previous_type" {
  enabled = false
}

$ tflint # no error

Version

$ tflint --version
TFLint version 0.24.0
+ ruleset.aws (0.2.0-bundled)

$ terraform version
Terraform v0.13.5
+ provider registry.terraform.io/hashicorp/aws v3.26.0
+ provider registry.terraform.io/hashicorp/template v2.2.0

debug log

$ tflint -v
TFLint version 0.24.0
+ ruleset.aws (0.2.0-bundled)

$ TFLINT_LOG=debug tflint
```console $ TFLINT_LOG=debug tflint 08:54:49 config.go:96: [INFO] Load config: .tflint.hcl 08:54:49 config.go:311: [DEBUG] Config loaded 08:54:49 config.go:312: [DEBUG] Module: false 08:54:49 config.go:313: [DEBUG] Force: false 08:54:49 config.go:314: [DEBUG] IgnoreModules: map[string]bool{} 08:54:49 config.go:315: [DEBUG] Varfiles: []string{} 08:54:49 config.go:316: [DEBUG] Variables: []string{} 08:54:49 config.go:317: [DEBUG] DisabledByDefault: false 08:54:49 config.go:318: [DEBUG] Rules: map[string]*tflint.RuleConfig{"aws_instance_previous_type":(*tflint.RuleConfig)(0xc0001e0b40)} 08:54:49 config.go:319: [DEBUG] Plugins: map[string]*tflint.PluginConfig{} 08:54:49 option.go:48: [DEBUG] CLI Options 08:54:49 option.go:49: [DEBUG] Module: false 08:54:49 option.go:50: [DEBUG] Force: false 08:54:49 option.go:51: [DEBUG] IgnoreModules: map[string]bool{} 08:54:49 option.go:52: [DEBUG] EnableRules: []string(nil) 08:54:49 option.go:53: [DEBUG] DisableRules: []string(nil) 08:54:49 option.go:54: [DEBUG] Only: []string(nil) 08:54:49 option.go:55: [DEBUG] Varfiles: []string{} 08:54:49 option.go:56: [DEBUG] Variables: []string{} 08:54:49 loader.go:57: [INFO] Initialize new loader 08:54:49 loader.go:82: [INFO] Load configurations under . 08:54:49 loader.go:90: [INFO] Module inspection is disabled. Building a root module without children... 08:54:49 loader.go:170: [INFO] Load values files 08:54:49 runner.go:50: [INFO] Initialize new runner for root 08:54:49 inspect.go:48: [INFO] AWS provider requirements found. Enable the plugin `aws` automatically 08:54:49 discovery.go:54: [INFO] Plugin `aws` is not installed, but bundled plugins are available. 08:54:49 discovery.go:68: [INFO] Plugin `aws` found 2021-02-01T08:54:49.303+0900 [DEBUG] plugin: starting plugin: path=/Users/shunsuke-suzuki/Documents/test/tflint/.akoi/bin/tflint args=[/Users/shunsuke-suzuki/Documents/test/tflint/.akoi/bin/tflint, --act-as-aws-plugin] 2021-02-01T08:54:49.305+0900 [DEBUG] plugin: plugin started: path=/Users/shunsuke-suzuki/Documents/test/tflint/.akoi/bin/tflint pid=86164 2021-02-01T08:54:49.305+0900 [DEBUG] plugin: waiting for RPC address: path=/Users/shunsuke-suzuki/Documents/test/tflint/.akoi/bin/tflint 2021-02-01T08:54:49.332+0900 [DEBUG] plugin: using plugin: version=8 2021-02-01T08:54:49.332+0900 [DEBUG] plugin.tflint: plugin address: address=/var/folders/w0/kzjzgvd52wg5s4jy5h0lcyqh0000gn/T/plugin832519963 network=unix timestamp=2021-02-01T08:54:49.332+0900 Failed to check rule config. An error occurred: Error: Rule not found: aws_instance_previous_type 2021-02-01T08:54:49.374+0900 [DEBUG] plugin.tflint: 08:54:49 rpc_server.go:48: [ERR] plugin: plugin server: accept unix /var/folders/w0/kzjzgvd52wg5s4jy5h0lcyqh0000gn/T/plugin832519963: use of closed network connection 2021-02-01T08:54:49.375+0900 [DEBUG] plugin: plugin process exited: path=/Users/shunsuke-suzuki/Documents/test/tflint/.akoi/bin/tflint pid=86164 2021-02-01T08:54:49.375+0900 [DEBUG] plugin: plugin exited ```

Note

I know there are breaking changes between v0.23.1 and v0.24.0. I read the release note of v0.24.0, but I can't find the change related to this issue.

https://github.com/terraform-linters/tflint/releases/tag/v0.24.0

wata727 commented 3 years ago

Thank you for reporting this. This bug is fixed in tflint-ruleset-aws v0.2.1 (TFLint v0.24.1 includes this plugin).

This problem was caused by https://github.com/terraform-linters/tflint/pull/1043. If you are interested, check PRs which is linked to the issue :)