terraform-linters / tflint

A Pluggable Terraform Linter
Mozilla Public License 2.0
4.98k stars 357 forks source link

Print the working directory on error in recursive inspection #1933

Closed wata727 closed 11 months ago

wata727 commented 11 months ago

After merging https://github.com/terraform-linters/tflint/pull/1918, errors are more likely to occur outside of the working directory as below.

$ tflint --recursive
Failed to check ruleset; Failed to check `google_monitoring_alert_policy_invalid_combiner` rule: modules/monitoring/alert/variables.tf:155,1-42: Incorrect variable type; The resolved value of variable "gae_app_memory_usage_threshold" is not appropriate: list of object required.

This is an error that occurred in a called module and is difficult to fix because looking at modules/monitoring/alert/variables.tf doesn't tell you who called that module.

This PR adds the current working directory to the error output in recursive inspection to help troubleshoot such issues.

$ tflint --recursive
Failed to check ruleset; Failed to check `google_monitoring_alert_policy_invalid_combiner` rule: modules/monitoring/alert/variables.tf:155,1-42: Incorrect variable type; The resolved value of variable "gae_app_memory_usage_threshold" is not appropriate: list of object required. working_dir=app1/staging