diff --git a/datadog/resource_datadog_service_level_objective.go b/datadog/resource_datadog_service_level_objective.go index cb08709b0..33011f8e6 100644 --- a/datadog/resource_datadog_service_level_objective.go +++ b/datadog/resource_datadog_service_level_objective.go @@ -97,6 +97,7 @@ func resourceDatadogServiceLevelObjective() *schema.Resource { StateFunc: func(val interface{}) string { return strings.TrimSpace(val.(string)) }, + ValidateFunc: validQueryOption, }, "denominator": { Type: schema.TypeString, @@ -104,6 +105,7 @@ func resourceDatadogServiceLevelObjective() *schema.Resource { StateFunc: func(val interface{}) string { return strings.TrimSpace(val.(string)) }, + ValidateFunc: validQueryOption, }, }, }, @@ -487,3 +489,13 @@ func suppressDataDogSLODisplayValueDiff(k, old, new string, d *schema.ResourceDa return suppressDataDogFloatIntDiff(k, old, new, d) } + +// validQueryOption validates that the `query` parameter is naively valid. +func validQueryOption(v interface{}, k string) (ws []string, errors []error) { + strVal := strings.TrimSpace(v.(string)) + if strVal == "" { + errors = append(errors, fmt.Errorf("empty `query.%s` specified for SLO", k)) + return + } + return +}