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

data datadog_monitors: allow queries that do not return value(s)

Open amolari opened this issue 11 months ago • 1 comments

What resources or data sources are affected?

data datadog_monitors

Feature Request

Please support a queries that do not return any monitor. The returned attribute "monitors" should then be simply an empty list. Example (as it would be seen in the TF state):

    {
      "module": "module.mymodule_datadog_events",
      "mode": "data",
      "type": "datadog_monitors",
      "name": "mydataresourcename",
      "provider": "provider[\"registry.terraform.io/datadog/datadog\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "id": "||team:teamA,service:serviceA,deploymentname:somevalue",
            "monitor_tags_filter": [
              "team:teamA",
              "service:serviceA",
              "deploymentname:somevalue"
            ],
            "monitors": [],
            "name_filter": null,
            "tags_filter": null
          },
          "sensitive_attributes": []
        }
      ]
    }

Using the provider v4.5.0, if the query doesn't return any list of monitor, it fails with such error:

Error: your query returned no result, please try a less specific search criteria
with module.mymodule_datadog_events.data.datadog_monitors.mydataresourcename
on .terraform/modules/mymodule_datadog_events/main.tf line 42, in data "datadog_monitors" "mydataresourcename":
data "datadog_monitors" "mydataresourcename" {

References

No response

amolari avatar Jan 16 '25 20:01 amolari

The fix has been merged so it will be available in next release version (we release around 1 time every 2 weeks)

ecdatadog avatar May 19 '25 06:05 ecdatadog