terraform-linters / tflint

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

Calls to terraform file functions fail in 0.44 with chdir/recursive #1633

Closed moritzzimmer closed 1 year ago

moritzzimmer commented 1 year ago

Summary

Using tflint with --chdir or --recursive fails to call terraform functions like filesha256 or file if the functions reference files using ${path.module}. In addition the tflint command exits with 1 even when --force flag is set.

Is there a way to support ${path.module} in combination with --chdir or --recursive ?

Command

tflint --chdir=$s -f compact --module --force --config=$ROOT_DIR/.tflint.hcl

Terraform Configuration

locals {
  config_hash    = filesha256("${path.module}/dashboards-proxy/default.conf.template")
}

TFLint Configuration

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

Output

modules/opensearch/dashboards_proxy.tf:2:20: error - Error in function call. Call to function "filesha256" failed: open modules/opensearch/dashboards-proxy/default.conf.template: no such file or directory.

TFLint Version

0.44.0

Terraform Version

No response

Operating System

wata727 commented 1 year ago

Thank you for reporting this. This bug is fixed in v0.44.1. https://github.com/terraform-linters/tflint/releases/tag/v0.44.1

moritzzimmer commented 1 year ago

nice, thx for the quick fix