hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.33k stars 1.73k forks source link

Unable to create an alert policy with COMPARISON_GE #16862

Open nbrys opened 10 months ago

nbrys commented 10 months ago

Community Note

Terraform Version

v1.3.3 and provider version 4.84.0

Affected Resource(s)

Terraform Configuration Files

# module.log_based_alerts["cmdfo-worker-onboarding-failure"].module.alerts.google_monitoring_alert_policy.main["alert-logging-metrics"] will be updated in-place
  ~ resource "google_monitoring_alert_policy" "main" {
        id                    = "projects/alert-test/alertPolicies/7216876910181223622"
        name                  = "projects/alert-test/alertPolicies/7216876910181223622"
        # (7 unchanged attributes hidden)

      ~ conditions {
            name         = "projects/alert-test/alertPolicies/7216876910181223622/conditions/7216876910181222287"
            # (1 unchanged attribute hidden)

          ~ condition_threshold {
              ~ comparison      = "COMPARISON_GT" -> "COMPARISON_GE"
                # (3 unchanged attributes hidden)

                # (1 unchanged block hidden)
            }
        }
    }

This gives the following error

ā•·
ā”‚ Error: Error updating AlertPolicy "projects/alert-test/alertPolicies/7216876910181223622": googleapi: Error 400: Field alert_policy.conditions[0].condition_threshold.comparison had an invalid value of "COMPARISON_GE": Unsupported comparison; only COMPARISON_LT and COMPARISON_GT are supported at present.
ā”‚ 
ā”‚   with module.log_based_alerts["cmdfo-worker-onboarding-failure"].module.alerts.google_monitoring_alert_policy.main["alert-logging-metrics"],
ā”‚   on .terraform/modules/log_based_alerts.alerts/main.tf line 30, in resource "google_monitoring_alert_policy" "main":
ā”‚   30: resource "google_monitoring_alert_policy" "main" {
ā”‚ 

Also the documentation is confusing: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_alert_policy#comparison

Only COMPARISON_LT and COMPARISON_GT are supported currently.

vs

Possible values are: COMPARISON_GT, COMPARISON_GE, COMPARISON_LT, COMPARISON_LE, COMPARISON_EQ, COMPARISON_NE

Expected Behavior

The alert to be created with a GE comparison

Actual Behavior

Unsupported comparison; only COMPARISON_LT and COMPARISON_GT are supported at present.

Steps to Reproduce

b/318495496

shuyama1 commented 10 months ago

@nbrys Sorry for the misleading documentation. Looks like the API only supports COMPARISON_LT and COMPARISON_GT currently (API doc). We'll correct the documentation for available values