diff --git a/internal/lang/funcs/filesystem.go b/internal/lang/funcs/filesystem.go index 289a09ea9083..276dd12ce40a 100644 --- a/internal/lang/funcs/filesystem.go +++ b/internal/lang/funcs/filesystem.go @@ -137,7 +137,7 @@ func MakeTemplateFileFunc(baseDir string, funcsCb func() (funcs map[string]funct vars, varsMarks := args[1].UnmarkDeep() - if !pathArg.IsKnown() { + if !pathArg.IsKnown() || !vars.IsKnown() { return cty.UnknownVal(retType).WithMarks(pathMarks, varsMarks), nil } diff --git a/internal/lang/funcs/filesystem_test.go b/internal/lang/funcs/filesystem_test.go index 5439661424c4..35d39c9036e8 100644 --- a/internal/lang/funcs/filesystem_test.go +++ b/internal/lang/funcs/filesystem_test.go @@ -216,6 +216,12 @@ func TestTemplateFile(t *testing.T) { cty.StringVal("- a\n- b\n- c\n").Mark("path").Mark("var"), ``, }, + { + cty.StringVal("testdata/list.tmpl").Mark("path"), + cty.UnknownVal(cty.Map(cty.String)), + cty.DynamicVal.Mark("path"), + ``, + }, { cty.StringVal("testdata/list.tmpl").Mark("path"), cty.ObjectVal(map[string]cty.Value{