Hello,
I cannot use the datadog_dashboard data structure because I am unable to dynamically send a multilevel object with various optional data (see Dynamic blocks with dynamic key? - #10 by cvalentin-dkt)
This is why I go through the json mode which also makes life easier for my users via the export of dashboards in datadog.
When i try this :
variable "example_json" {
type = string
validation {
condition = (
can(jsondecode(var.dashboard)) ?
(regex("^[Monitoring]", jsondecode(var.dashboard).title)) :
false
)
error_message = "Must be valid JSON and have Title set to \"example\"."
}
}
I can’t use regex here
│ on ../terraform-modules/monitoring-datadog-terraform-dashboard-v2/variables.tf line 56, in variable "dashboard":
│ 56: (regex("^[Monitoring]", jsondecode(var.dashboard).title)) :
Call to function "regex" failed: pattern did not match any part of the given string.
So I try like this, but I have the regex can not find me the necessary fields :
variable "dashboard" {
type = string
description = "The JSON formatted definition of the Dashboard."
validation {
condition = can(regex("^[(Test|Test1|Test2)]", jsondecode(var.dashboard).title))
error_message = "Dashboard Title must be contain prefix business_department, Format : [business_department] NAME."
}
}
Any idea ?
I would just like to check that the title field of the json does indeed contain a potential list of values in prefix in the format [PREFIX] …