terraform-linters / tflint

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

Call to unknown function; There is no function named "templatestring". #2149

Closed jacekgajek closed 3 weeks ago

jacekgajek commented 3 weeks ago

Summary

tflint fails with the following error:

failed to check "aws_iam_role_policy_invalid_policy" rule: Call to unknown function; There is no function named "templatestring".

Note that I don't know how to check tflint version as I don't have it installed locally, it's configured in terragrunt before_hooks. It probably uses the latest version.

Command

tflint

Terraform Configuration

resource "aws_iam_role_policy" "attach_inline_policy" {
  name   = "inline_policy_bucket_access"
  role   = aws_iam_role.main.id
  policy = templatestring(var.role_policy_document_template, var.role_policy_document_template_vars)
}

TFLint Configuration

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

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

rule "terraform_required_providers" {
  enabled = false
}

rule "terraform_documented_outputs" {
  enabled = false
}

Output

Failed to check ruleset; failed to check "aws_iam_role_policy_invalid_policy" rule: .terragrunt-cache/h68AU01RTSPm2DqhoIvafyVeK5U/LUUdbm_N5gK8Wwbe1TRb_I5ASMU/modules/base-modules/iam-role-service/main.tf:21,12-26: Call to unknown function; There is no function named "templatestring".

TFLint Version

0.53.0

Terraform Version

1.9.4

Operating System

wata727 commented 3 weeks ago

The templatestring function is supported in v0.52 and this error does not occur in the latest version. If you have steps to reproduce the issue in the latest version, please reopen the issue with the steps.