DataDog / terraform-provider-datadog

Terraform Datadog provider
https://www.terraform.io/docs/providers/datadog/
Mozilla Public License 2.0
400 stars 376 forks source link

[Feature Request] Option to verify assertions #775

Open walkafwalka opened 3 years ago

walkafwalka commented 3 years ago

A misconfiguration in a synthetic test attached to an SLO could result in false downtime. In the UI, we typically run "Test URL" after we make changes to verify our changes before saving.

This feature request is to essentially replicate the "Test URL" function in the UI by running the test with the new configuration and failing the apply if the test fails.

Note that according to support, there is an "upcoming feature called SLO Status Corrections which will allow you to specify time periods you want an SLO to ignore in its status calculation". This would be a reasonable workaround, but I still think it is a better practice to avoid using "SLO Status Corrections" to address misconfigurations.

Affected Resource(s)

Terraform Configuration Files

resource "datadog_synthetics_test" "test_api" {
  type = "api"
  subtype = "http"

  request = {
    method = "GET"
    url = "https://www.example.org"
  }

  assertion {
      type = "statusCode"
      operator = "is"
      target = "200"
  }

...

  verify_assertions = true
}

Expected Behavior

On initial configuration or changes to any assertion, the test would be run in Datadog and Terraform would only apply if the test was successful.

walkafwalka commented 3 years ago

vault_database_secret_backend_connection has a similar feature, verify_connection, that verifies the vault instance can connect to the database it is being configured to connect to.

walkafwalka commented 3 years ago

I found the undocumented API that is used for the "Test URL" function: https://app.datadoghq.com/api/v1/synthetics/tests/fast.

Unfortunately, I could not authenticate via DD-API-KEY and had to use cookie authentication so this would likely require Datadog making this API available to the public.

sdeprez commented 3 years ago

Hi @walkafwalka,

This is an interesting request, unfortunately this is quite challenging technically and would require significant changes on Datadog backend side, so it's likely it won't be implemented in short term (but we'll keep that in mind!).

walkafwalka commented 3 years ago

I figured as much. Nevertheless, I appreciate the update.