terraform计划给出错误:函数调用(函数yamldecode)

时间:2020-09-15 12:27:35

标签: elasticsearch kubernetes terraform

请找到我们正在使用的Terraform脚本的GitLab存储库。 enter link description here 在terraform计划中运行会在弹性搜索的多合一YAML文件中给出以下错误。

Error: Error in function call
 on kubernetes.tf line 49, in locals:
 49:   resource_list = yamldecode(file("${path. module}/all-in-one.yaml")).items
   |----------------
   | path.module is "."

Call to function `"yamldecode"` failed: on line 458, column 1: unexpected extra
content after value.

enter image description here

1 个答案:

答案 0 :(得分:1)

the fine manual中所述:

仅允许使用一个YAML文档。如果给定字符串中存在多个文档,则此函数将返回错误。

并且可以轻松重现您的错误消息:

  content  = yamldecode("---\nhello: world\n---\ntoo: bad\n")
  on main.tf line 14, in resource "local_file" "example":
  14:   content  = yamldecode("---\nhello: world\n---\ntoo: bad\n")

Call to function "yamldecode" failed: on line 2, column 1: unexpected extra
content after value.