表达的地形和多个列表
我想使用以下来表达式使用TF 0.13.7创建CloudWatch仪表板 变量:
variable "redis_replicas" {
type = list(map(string))
default = [
{
name = "test-eucentral1-redis-001"
region = "eu-central-1"
},
locals {
replicas = [for i in var.redis_replicas: i.name]
regions = [for i in var.redis_replicas: i.region]
计划的资源
resource "aws_cloudwatch_dashboard" "cloudwatch_db_redis" {
dashboard_name = "Redis-Performance"
dashboard_body = jsonencode({
widgets : concat(local.body1)
})
}
body1 = [
{
height = 6
properties = {
metrics = [ for replica in local.replicas :
[
{
expression = "m1"
id = "e1"
},
], # getting error here
[
"AWS/ElastiCache",
"ClusterBasedCmds",
"CacheClusterId",
replica,
],
]
view = "timeSeries"
}
type = "metric"
}
]
使用
metrics = [for instance in var.redis_replicas : [
[],
[],
]
工作,但适用是失败的。
Error: Putting dashboard failed: InvalidParameterInput: The dashboard body is invalid, there are 50 validation errors:
[
{
"dataPath": "/widgets/9/properties/metrics/0/0",
"message": "Invalid metric field type, only \"String\" type is allowed"
},
知道如何结合这两个吗? 如果我在身体上做的话,它可以使用,但是我有不同的副本的图形。
I want to use following for expression to create CloudWatch dashboard using TF 0.13.7
Variables:
variable "redis_replicas" {
type = list(map(string))
default = [
{
name = "test-eucentral1-redis-001"
region = "eu-central-1"
},
locals {
replicas = [for i in var.redis_replicas: i.name]
regions = [for i in var.redis_replicas: i.region]
resources
resource "aws_cloudwatch_dashboard" "cloudwatch_db_redis" {
dashboard_name = "Redis-Performance"
dashboard_body = jsonencode({
widgets : concat(local.body1)
})
}
body1 = [
{
height = 6
properties = {
metrics = [ for replica in local.replicas :
[
{
expression = "m1"
id = "e1"
},
], # getting error here
[
"AWS/ElastiCache",
"ClusterBasedCmds",
"CacheClusterId",
replica,
],
]
view = "timeSeries"
}
type = "metric"
}
]
Using
metrics = [for instance in var.redis_replicas : [
[],
[],
]
Plan works but apply is failing.
Error: Putting dashboard failed: InvalidParameterInput: The dashboard body is invalid, there are 50 validation errors:
[
{
"dataPath": "/widgets/9/properties/metrics/0/0",
"message": "Invalid metric field type, only \"String\" type is allowed"
},
Any idea how to combine those two?
It works if I do for in body but then I have different graphs for different replica.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论