dashboard_body内的模板文件

问题描述

我想知道是否有可能在dashboard_body资源中使用模板文件。我正在尝试以下方法。

     dashboard_body = <<EOF
{
  "widgets": [
    {
      "type": "metric","x": 0,"y": 0,"width": 12,"height": 6,"properties": {
        "metrics": [
          templatefile("${path.module}/backends.tmpl",{ instances = aws_instance.web })
        ],"period": 300,"stat": "Average","region": "us-east-1","title": "EC2 Instance CPU"
      }
    }
  ]
}
EOF

使用模板文件

%{ for instance in instances ~}
          [
            "AWS/EC2","CPUUtilization","InstanceId","${instance.id}"
          ]
%{ endfor ~}

但是,当我运行Terraform Apply时,出现以下错误消息。

错误:“ dashboard_body”包含无效的JSON:字面值为true的无效字符“ e”(预期为“ r”)

在dashboards.tf第1行中,在资源“ aws_cloudwatch_dashboard”“ main”中: 1:资源“ aws_cloudwatch_dashboard”“主要” {

预先感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)