-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feature request) Validate monitor during plan with datadog api #414
Comments
This is a big problem for me as well. Master breaks when people merge monitors because it gets applied and the queries are invalid. Adding the validate API check would be great. |
I had a crack at this, it's not trivial. First, terraform doesn't have a general validate hook for resources. The best next thing I could think of was to use It seems to work OK, but it has a big caveat: at that point, we don't necessarily have all data (for example, if fields depend on non-created resources). It manifested in the tests with composite monitors. The trick is to skip validation in that particular case, but I'm a bit worried to miss another case, and that would block people from doing anything (plan fails, and you're stuck). Any input appreciated, thanks. |
Would writing a custom |
|
Good point! |
Some links to upstream issues and other discussions, for posterity:
It seems there may be no easy solutions on the horizon here. I'll just reiterate the value of having SOME validation of the query string though. The vast majority of the complexity (and apply-time errors) associated with the monitor resource come from that string, which is currently completely opaque to terraform. I know teams that are building their own incomplete string-builders to try to reduce apply-time errors. Having something at plan time that weeds out obvious invalid query-strings would speed up the debugging cycle for slow applies, even if it has false negatives (like allowing a query-string that would be valid for a different monitor type... which isn't a common real-world error and allowing it through is no worse than the behavior today). |
Using CustomizeDiff, we can call the validation API to provide more validation for monitor creation. This allows returning an error during the `plan` phase, instead of waiting for `apply`. Closes #414
TBH, just validating the query would be huge. That's 99% of my validation failures. |
* Validate monitor in pre-flight Using CustomizeDiff, we can call the validation API to provide more validation for monitor creation. This allows returning an error during the `plan` phase, instead of waiting for `apply`. Closes #414 * Fix tests, update cassettes * Add some more checks, allow disabling validation * Be a bit more creative in validate use * Always suppress from diff * Fix comment
This is a feature request same as https://github.com/terraform-providers/terraform-provider-datadog/issues/66 (closed) - datadog now provides
/validate
endpoint which I believe can be used by terraform-provider-datadog.Terraform Version
0.12.19
Affected Resource(s)
Terraform Configuration Files
Note query field is invalid (no closing
}
). Other fields are not relevant with issue.Expected Behavior
terraform plan
fails because this is invalid monitor definitionActual Behavior
terraform plan
succeeds, however when you runterraform apply
you will get errorSteps to Reproduce
terraform plan
-> no errorterraform apply
-> errorReferences
https://github.com/terraform-providers/terraform-provider-datadog/issues/66 was closed due to philosophy that we shouldn't duplicate validation logic on provider side. However datadog provides /validate endpoint that could be used https://docs.datadoghq.com/api/?lang=bash#validate-a-monitor
The text was updated successfully, but these errors were encountered: