【问题标题】:terraform plan is giving the error : function call (function yamldecode)terraform plan 给出错误:函数调用(函数 yamldecode)
【发布时间】:2021-01-02 05:02:51
【问题描述】:

请找到我们正在使用的 terraform 脚本的 GitLab 存储库。 enter link description here Run in terraform plan 在用于弹性搜索的 all-in-one.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

【问题讨论】:

  • 代码第 29 行的 path.module 之间可能不应该有空格
  • 嗨,Patrick,我们也尝试不使用空格和空格,但仍然出现同样的错误。
  • 请不要在代码 sn-ps 中使用图像,因为它非常难以阅读并且没有索引以供搜索。在how to ask 页面中明确提及

标签: elasticsearch kubernetes terraform


【解决方案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.

【讨论】:

  • 嗨,Daniel,我已经尝试拆分这个 all-in-one.yaml 文件(download.elastic.co/downloads/eck/1.2.0/all-in-one.yaml)并得到了错误。
  • 错误:apmservers.apm.k8s.elastic.co 未能创建 kubernetes REST 客户端以更新资源:资源 [apiextensions.k8s.io/v1beta1/CustomResourceDefinition] 对集群无效,请检查APIVersion 和 Kind 字段有效。在 kubernetes.tf 第 32 行,在资源“kubectl_manifest”“all-in-one”中:32:资源“kubectl_manifest”“all-in-one”{
  • 这听起来像是一个新问题,这个新问题属于ServerFault.com,因为这个问题与编程无关
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多