Thanks @mathias213. Problem is i want to have different types of widgets that is pulled from .tfvars. So for example alert_value_definition i want to be passed in from .tfvars
Due to how this provider’s schema is designed, there’s no way to write a single generic block that covers all of the possible nested block types. Instead, I think you’ll need to write out a definition for each of the block types you might want to generate and for each one write block content that is valid for that particular block type (since each of them has a separate content schema).
I’m not familiar with this provider at all, so I’m relying only on what’s in the documentation, but it looks like they have a separate datadog_dashboard_json resource type which allows specifying the dashboard configuration as a single JSON string that the provider presumably validates using its own internal rules, rather than asking Terraform Core to enforce a particular schema itself. Given that, you may be able to more easily get the result you were hoping for by dynamically constructing a JSON value instead. For example:
The above assumes that var.widgets has a type which jsonencode will convert into the JSON structure that this widgets property expects. If not, you may need to transform it using a for expression.
Depending on how this other resource type is implemented in the provider, this might mean that the dashboard isn’t validated as strongly at planning time as it would be for the datadog_dashboard resource type (for example, if it’s relying only on the remote API for some parts of its validation), but in return you get the flexibility of constructing this data structure however you like because from Terraform’s own perspective this is just a big string it knows nothing about.
@jpashby Did you find solution for this. Looking for exact setup for a widget inside a dashboard. That would iterate from a map of objects to create several equal widgets in same dashboard. Would be curious to know if you made it.