400尝试多次循环小部件字段时Terraform代码中出现错误
我收到以下错误错误: 错误:放置仪表板失败:InvalidParameterInput:仪表板主体无效,存在4个验证错误: [ { “数据路径”:“/widgets/0”, “消息”:“应该是对象” }, { “数据路径”:“/widgets/1”, “消息”:“应该是对象” }, { “数据路径”:“/widgets/2”, “消息”:“应该是对象” }, { “数据路径”:“/widgets/3”, “消息”:“应该是对象” } ]400尝试多次循环小部件字段时Terraform代码中出现错误,terraform,terraform-provider-aws,Terraform,Terraform Provider Aws,我收到以下错误错误: 错误:放置仪表板失败:InvalidParameterInput:仪表板主体无效,存在4个验证错误: [ { “数据路径”:“/widgets/0”, “消息”:“应该是对象” }, { “数据路径”:“/widgets/1”, “消息”:“应该是对象” }, { “数据路径”:“/widgets/2”, “消息”:“应该是对象” }, { “数据路径”:“/widgets/3”, “消息”:“应该是对象” } ] 状态代码:400,请求id:706ac87c-a796-1
状态代码:400,请求id:706ac87c-a796-11e9-8983-65d87c7656b4,代码生成如下所示
{
“小部件”:[
[ //
I have the following code which I am trying to implement for multiple widgets in a single cloud watch dashboard
` locals {
instances = csvdecode(file("${path.module}/sample.csv"))
}
resource "aws_cloudwatch_dashboard" "main" {
dashboard_name = "my-dashboard"
dashboard_body = jsonencode(
{
"widgets": [
for inst in range(length(local.instances)):[
// i want to repeat the below section as the length of instances variable but getting an error
{
"type":"metric",
"x":0,
"y":0,
"width":12,
"height":6,
"properties":{
"metrics":[ // trying to implement multiple widget in a single dashboard
enter code here
[
"AWS/EC2",
"CPUUtilization",
"InstanceId",
"${local.instances[inst].instance_id}"
]
],
"period":300,
"stat":"Average",
"region":"ap-south-1",
"title":"EC2 Instance CPU",
"annotations": {
"horizontal": [
{
"label": "Untitled annotation",
"value": 1.01
}]
} }
}
]]
})
} `