terraform-provider-datadog icon indicating copy to clipboard operation
terraform-provider-datadog copied to clipboard

Don't throw error if data source resource can not be found

Open arruw opened this issue 1 year ago • 1 comments

I would like to get null value from a data source instead of an error (link), so I can handle this case in a script and conditionally decide what to do with it.

Currently I would like to do this on datadog_dashboard data source, but I imagine this could be useful elsewhere too.

I am proposing we add return_null_if_not_found property on the data source definitions, which should be by default set to false. That way we keep plugin backward compatible.

arruw avatar Mar 07 '24 13:03 arruw

Hello, It is usually the philosophy of terraform datasource to :

  • have a singular datasource (example : datadog_monitor) that will succeed only if there is exactly one object that matches the criteria (fails if 0 or more than one object is returned)
  • have a plural datasource (example : datadog_monitors) that will returns an array of objects (monitor in our case) and so having 0, 1 or more objects matching the criteria can be handled by users

Do you need datadog_dashboards datasources or other datasources in "plural" form ?

ecdatadog avatar Jan 20 '25 15:01 ecdatadog