The makeup of a Datadog template_variable_preset:
### Nested
template_variable_preset` blocks
Nested template_variable_preset
blocks have the following structure:
-
name
- (Required) The displayed name of the preset. -
template_variable
: (Required) Block describing the values that a template_variable within this preset should assume. Each referenced template_variable name must be defined on the dashboard, but not all template_variables must be included in a preset. One or more blocks can be defined per preset.
A developer can include a variable number of these in a terraform configuration for a dashboard. I have attempted all sorts of ways to deal with this object type, including:
variable "template_variable_presets" {
type = map(object({
names = set(string)
}))
default = {
tvar1 = ["name", "value"]
tvar2 = ["name", "value"]
}
description = "Nested block describing saved configurations of existing template variables. Multiple template_variable_preset blocks are allowed within a datadog_dashboard resource, and multiple template_variables can be described by each template_variable_preset."
}
and, locals…
t_presets = flatten([
for tpn, obj in var.template_variable_presets : [
for tvar in obj.names : {
name = tpn
value = tvar
}
]
])
That produces this error:
Error: Invalid default value for variable
on variables.tf line 32, in variable "template_variable_presets":
32: default = {
33: tvar1 = ["name", "value"],
34: tvar2 = ["name", "value"]
35: }
This default value is not compatible with the variable's type constraint:
element "tvar2": object required.
What is the proper way to go about this?