terraform-linters / tflint

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

Inspect of submodule not working #1211

Closed dqfiliptvrdon closed 3 years ago

dqfiliptvrdon commented 3 years ago

Inspect of submodule with option --module or with config module=true not working. Inspect is finnished only on main file and all submodules errors are ignored.

Current output:

2 issue(s) found:

Error: "StorageXX" is an invalid value as account_kind (azurerm_storage_account_invalid_account_kind)

  on main.tf line 48:
  48:   account_kind = "StorageXX" # bad definition of acount kind, correct is Storage

Reference: https://github.com/terraform-linters/tflint-ruleset-azurerm/blob/v0.12.0/docs/rules/azurerm_storage_account_invalid_account_kind.md

Warning: Module should include an empty outputs.tf file (terraform_standard_module_structure)

  on outputs.tf line 1:
   (source code not available)

Reference: https://github.com/terraform-linters/tflint/blob/v0.31.0/docs/rules/terraform_standard_module_structure.md

Expected output:

3 issue(s) found:

Error: "StorageXX" is an invalid value as account_kind (azurerm_storage_account_invalid_account_kind)

  on main.tf line 48:
  48:   account_kind = "StorageXX" # bad definition of acount kind, correct is Storage

Reference: https://github.com/terraform-linters/tflint-ruleset-azurerm/blob/v0.12.0/docs/rules/azurerm_storage_account_invalid_account_kind.md

Warning: Module should include an empty outputs.tf file (terraform_standard_module_structure)

  on outputs.tf line 1:
   (source code not available)

Reference: https://github.com/terraform-linters/tflint/blob/v0.31.0/docs/rules/terraform_standard_module_structure.md

Error: "StorageXX" is an invalid value as account_kind (azurerm_storage_account_invalid_account_kind)

  on modules/remotestate/main.tf line 41:
  41:   account_kind = "StorageXKZK" # bad definition of acount kind, correct is Storage

Reference: https://github.com/terraform-linters/tflint-ruleset-azurerm/blob/v0.12.0/docs/rules/azurerm_storage_account_invalid_account_kind.md

I attach sample project file TFLint_example.zip with 2 errors in azurerm_storage_account_invalid_account_kind. One is in main.tf and second in ./modules/remotestate/main.tf.

config {
  module = true
  force = true
  disabled_by_default = false

  varfile = [
    "conf.tfvars"]
}

plugin "azurerm" {
  enabled = true
  version = "0.12.0"
  source = "github.com/terraform-linters/tflint-ruleset-azurerm"
}

#docs https://github.com/terraform-linters/tflint/tree/master/docs/rules
rule "terraform_unused_declarations" {
  enabled = true
}

rule "terraform_comment_syntax" {
  enabled = true
}

rule "terraform_required_providers" {
  enabled = true
}

rule "terraform_unused_required_providers" {
  enabled = true
}

rule "terraform_standard_module_structure" {
  enabled = true
}

rule "terraform_typed_variables" {
  enabled = true
}

rule "terraform_documented_variables" {
  enabled = true
}

rule "terraform_documented_outputs" {
  enabled = true
}

Version

$ tflint -v
TFLint version 0.31.0
+ ruleset.azurerm (0.12.0)te
$ terraform -v
Terraform v1.0.5
on linux_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.75.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
bendrucker commented 3 years ago

Working as expected, see the clarified docs I just wrote here:

https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/module-inspection.md