Skip to content

Commit

Permalink
Merge pull request #2789 from Nmishin/fix/2759
Browse files Browse the repository at this point in the history
Implement the 'group_by', 'where' and 'actions' options for cloudflare_notification_policy
  • Loading branch information
jacobbednarz authored Sep 25, 2023
2 parents 6a1a736 + f94bca0 commit 8fc42d1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changelog/2789.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/cloudflare_notification_policy: Implement the `group_by`, `where` and `actions` options
```

```release-note:enhancement
resource/cloudflare_notification_policy: Add `advanced_http_alert_error` alert_type
```
5 changes: 4 additions & 1 deletion docs/resources/notification_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ resource "cloudflare_notification_policy" "example" {
### Required

- `account_id` (String) The account identifier to target for the resource.
- `alert_type` (String) The event type that will trigger the dispatch of a notification. See the developer documentation for descriptions of [available alert types](https://developers.cloudflare.com/fundamentals/notifications/notification-available/). Available values: `access_custom_certificate_expiration_type`, `advanced_ddos_attack_l4_alert`, `advanced_ddos_attack_l7_alert`, `bgp_hijack_notification`, `billing_usage_alert`, `block_notification_block_removed`, `block_notification_new_block`, `block_notification_review_rejected`, `clickhouse_alert_fw_anomaly`, `clickhouse_alert_fw_ent_anomaly`, `custom_ssl_certificate_event_type`, `dedicated_ssl_certificate_event_type`, `dos_attack_l4`, `dos_attack_l7`, `expiring_service_token_alert`, `failing_logpush_job_disabled_alert`, `fbm_auto_advertisement`, `fbm_dosd_attack`, `fbm_volumetric_attack`, `health_check_status_notification`, `hostname_aop_custom_certificate_expiration_type`, `http_alert_edge_error`, `http_alert_origin_error`, `load_balancing_health_alert`, `load_balancing_pool_enablement_alert`, `real_origin_monitoring`, `scriptmonitor_alert_new_code_change_detections`, `scriptmonitor_alert_new_hosts`, `scriptmonitor_alert_new_malicious_hosts`, `scriptmonitor_alert_new_malicious_scripts`, `scriptmonitor_alert_new_malicious_url`, `scriptmonitor_alert_new_max_length_resource_url`, `scriptmonitor_alert_new_resources`, `secondary_dns_all_primaries_failing`, `secondary_dns_primaries_failing`, `secondary_dns_zone_successfully_updated`, `secondary_dns_zone_validation_warning`, `sentinel_alert`, `stream_live_notifications`, `tunnel_health_event`, `tunnel_update_event`, `universal_ssl_event_type`, `web_analytics_metrics_update`, `weekly_account_overview`, `workers_alert`, `zone_aop_custom_certificate_expiration_type`.
- `alert_type` (String) The event type that will trigger the dispatch of a notification. See the developer documentation for descriptions of [available alert types](https://developers.cloudflare.com/fundamentals/notifications/notification-available/). Available values: `advanced_http_alert_error`, `access_custom_certificate_expiration_type`, `advanced_ddos_attack_l4_alert`, `advanced_ddos_attack_l7_alert`, `bgp_hijack_notification`, `billing_usage_alert`, `block_notification_block_removed`, `block_notification_new_block`, `block_notification_review_rejected`, `clickhouse_alert_fw_anomaly`, `clickhouse_alert_fw_ent_anomaly`, `custom_ssl_certificate_event_type`, `dedicated_ssl_certificate_event_type`, `dos_attack_l4`, `dos_attack_l7`, `expiring_service_token_alert`, `failing_logpush_job_disabled_alert`, `fbm_auto_advertisement`, `fbm_dosd_attack`, `fbm_volumetric_attack`, `health_check_status_notification`, `hostname_aop_custom_certificate_expiration_type`, `http_alert_edge_error`, `http_alert_origin_error`, `load_balancing_health_alert`, `load_balancing_pool_enablement_alert`, `real_origin_monitoring`, `scriptmonitor_alert_new_code_change_detections`, `scriptmonitor_alert_new_hosts`, `scriptmonitor_alert_new_malicious_hosts`, `scriptmonitor_alert_new_malicious_scripts`, `scriptmonitor_alert_new_malicious_url`, `scriptmonitor_alert_new_max_length_resource_url`, `scriptmonitor_alert_new_resources`, `secondary_dns_all_primaries_failing`, `secondary_dns_primaries_failing`, `secondary_dns_zone_successfully_updated`, `secondary_dns_zone_validation_warning`, `sentinel_alert`, `stream_live_notifications`, `tunnel_health_event`, `tunnel_update_event`, `universal_ssl_event_type`, `web_analytics_metrics_update`, `weekly_account_overview`, `workers_alert`, `zone_aop_custom_certificate_expiration_type`.
- `enabled` (Boolean) The status of the notification policy.
- `name` (String) The name of the notification policy.

Expand Down Expand Up @@ -103,12 +103,14 @@ Read-Only:

Optional:

- `actions` (Set of String) Targeted actions for alert.
- `alert_trigger_preferences` (Set of String) Alert trigger preferences. Example: `slo`.
- `enabled` (Set of String) State of the pool to alert on.
- `environment` (Set of String) Environment of pages. Available values: `ENVIRONMENT_PREVIEW`, `ENVIRONMENT_PRODUCTION`.
- `event` (Set of String) Pages event to alert. Available values: `EVENT_DEPLOYMENT_STARTED`, `EVENT_DEPLOYMENT_FAILED`, `EVENT_DEPLOYMENT_SUCCESS`.
- `event_source` (Set of String) Source configuration to alert on for pool or origin.
- `event_type` (Set of String) Stream event type to alert on.
- `group_by` (Set of String) Alert grouping.
- `health_check_id` (Set of String) Identifier health check. Required when using `filters.0.status`.
- `input_id` (Set of String) Stream input id to alert on.
- `limit` (Set of String) A numerical limit. Example: `100`.
Expand All @@ -125,6 +127,7 @@ Optional:
- `status` (Set of String) Status to alert on.
- `target_hostname` (Set of String) Target host to alert on for dos.
- `target_zone_name` (Set of String) Target domain to alert on.
- `where` (Set of String) Filter for alert.
- `zones` (Set of String) A list of zone identifiers.


Expand Down
24 changes: 24 additions & 0 deletions internal/sdkv2provider/schema_cloudflare_notification_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func resourceCloudflareNotificationPolicySchema() map[string]*schema.Schema {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"advanced_http_alert_error",
"access_custom_certificate_expiration_type",
"advanced_ddos_attack_l4_alert",
"advanced_ddos_attack_l7_alert",
Expand Down Expand Up @@ -83,6 +84,7 @@ func resourceCloudflareNotificationPolicySchema() map[string]*schema.Schema {
"zone_aop_custom_certificate_expiration_type",
}, false),
Description: fmt.Sprintf("The event type that will trigger the dispatch of a notification. See the developer documentation for descriptions of [available alert types](https://developers.cloudflare.com/fundamentals/notifications/notification-available/). %s", renderAvailableDocumentationValuesStringSlice([]string{
"advanced_http_alert_error",
"access_custom_certificate_expiration_type",
"advanced_ddos_attack_l4_alert",
"advanced_ddos_attack_l7_alert",
Expand Down Expand Up @@ -184,6 +186,12 @@ func notificationPolicyFilterSchema() *schema.Schema {
Description: "An optional nested block of filters that applies to the selected `alert_type`. A key-value map that specifies the type of filter and the values to match against (refer to the alert type block for available fields).",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"actions": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "Targeted actions for alert.",
},
"status": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Expand Down Expand Up @@ -252,6 +260,22 @@ func notificationPolicyFilterSchema() *schema.Schema {
Optional: true,
Description: "A numerical limit. Example: `99.9`.",
},
"where": {
Type: schema.TypeSet,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
Description: "Filter for alert.",
},
"group_by": {
Type: schema.TypeSet,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
Description: "Alert grouping.",
},
"alert_trigger_preferences": {
Type: schema.TypeSet,
Elem: &schema.Schema{
Expand Down

0 comments on commit 8fc42d1

Please sign in to comment.