cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
786 stars 609 forks source link

cloudflare_notification_policy filter selectors not working #2935

Closed zeroschism closed 11 months ago

zeroschism commented 12 months ago

Confirmation

Terraform and Cloudflare provider version

Terraform v1.5.7 cloudflare provider 4.18.0

Affected resource(s)

clouflare_notification_policy

Terraform configuration files

resource "cloudflare_notification_policy" "drop_in_http_success" {
  account_id  = var.cloudflare_account_id
  name        = "Significant drop in HTTP 200 responses"
  description = ""
  enabled     = true
  alert_type  = "traffic_anomalies_alert"

  pagerduty_integration {
    id   = local.pd_L7_noncritical
  }

  filters {
    alert_trigger_preferences = [
        "zscore_drop"
    ]
    group_by = [
        "zone"
    ]
    selectors = [
        "total"
    ]
    where = [
        "(originStatusCodeFilter eq 200)"
    ]
    zones = local.notification_zones

  }
}

Link to debug output

https://gist.github.com/zeroschism/efa6bb07b7548e2bb80c8ac8e4e48614

Panic output

No response

Expected output

cloudflare_notification_policy.drop_in_http_success: Importing from ID "/"... cloudflare_notification_policy.drop_in_http_success: Import prepared! Prepared cloudflare_notification_policy for import cloudflare_notification_policy.drop_in_http_success: Refreshing state... [id=REDACTED]

Import successful!

The resources that were imported are shown above. These resources are now in your Terraform state and will henceforth be managed by Terraform.

Actual output

Error: failed to set filters: Invalid address to set: []string{"filters", "0", "selectors"}

Steps to reproduce

  1. Create a "Traffic Monitoring -> Traffic Anomalies" notification in the web UI
  2. Attempt to import the policy: terraform import <account id>/<policy id>

Additional factoids

I believe this selectors element is also relevant for the magic_tunnel_health_check_event alert type as using the API directly to list policies yields:

 "selectors": [
          "failures"
        ],

It is mentioned/referenced in the API docs as well

References

No response

github-actions[bot] commented 12 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue