Trying to use Dynamic blocks for metric query and metric on cloudwatch alarm. But the block does not recognize the optional arguments.
variable “metric_query” {
type = map(object({
id = string
account_id = string
expression = string
label = string
return_data = string
metric = set(object({
metric_dimensions = map(any)
metric_block_name = string
metric_namespace = string
metric_period = string
stat = string
metric_unit = string
}))
}))
default = null
And this is how am trying to declare the values for the object when I invoke the module.
treat_missing_data = “notBreaching”
metric_query = [{
id = "e1"
account_id = ""
expression = "m2/m1*100"
label = "Error Rate"
return_data = "true"
metric = [{
metric_block_name = null
metric_namespace = "AWS/EC2"
metric_period = "120"
stat = "Average"
metric_unit = "Count"
metric_dimensions = { InstanceId = "i-abc123" }
}]
},
{
id = "m1"
return_data = "true"
account_id = ""
expression = ""
label = ""
metric = [{
metric_block_name = "CPUUtilization"
metric_namespace = "AWS/EC2"
metric_period = "120"
stat = "Average"
metric_unit = "Count"
metric_dimensions = { InstanceId = "i-abc123" }
}]
}
]
dimensions = {
FunctionName : module.function.lambda_function_name
}
}