pagerduty_event_orchestration_service_cache_variable

A Cache Variable can be created on a Service Event Orchestration, in order to temporarily store event data to be referenced later within the Service Event Orchestration

Example of configuring a Cache Variable for a Service Event Orchestration

This example shows creating a service Event Orchestration and a Cache Variable. This Cache Variable will count and store the number of trigger events with 'database' in its title. Then all alerts sent to this Event Orchestration will have its severity upped to 'critical' if the count has reached at least 5 triggers within the last 1 minute.

resource "pagerduty_team" "database_team" {
  name = "Database Team"
}

resource "pagerduty_user" "user_1" {
  name  = "Earline Greenholt"
  email = "125.greenholt.earline@graham.name"
  teams = [pagerduty_team.database_team.id]
}

resource "pagerduty_escalation_policy" "db_ep" {
  name      = "Database Escalation Policy"
  num_loops = 2

  rule {
    escalation_delay_in_minutes = 10
    target {
      type = "user"
      id   = pagerduty_user.user_1.id
    }
  }
}

resource "pagerduty_service" "svc" {
  name                    = "My Database Service"
  auto_resolve_timeout    = 14400
  acknowledgement_timeout = 600
  escalation_policy       = pagerduty_escalation_policy.db_ep.id
  alert_creation          = "create_alerts_and_incidents"
}

resource "pagerduty_event_orchestration_service_cache_variable" "num_db_triggers" {
  service = pagerduty_service.svc.id
  name = "num_db_triggers"

  condition {
    expression = "event.summary matches part 'database'"
  }

  configuration {
    type = "trigger_event_count"
    ttl_seconds = 60
  }
}

resource "pagerduty_event_orchestration_service" "event_orchestration" {
  service = pagerduty_service.svc.id
  enable_event_orchestration_for_service = true

  set {
    id = "start"
    rule {
      label = "Set severity to critical if we see at least 5 triggers on the DB within the last 1 minute"
      condition {
        expression = "cache_var.num_db_triggers >= 5"
      }
      actions {
        severity = "critical"
      }
    }
  }

  catch_all {
    actions { }
  }
}

Argument Reference

The following arguments are supported:

Attributes Reference

The following attributes are exported:

Import

Cache Variables can be imported using colon-separated IDs, which is the combination of the Service Event Orchestration ID followed by the Cache Variable ID, e.g.

$ terraform import pagerduty_event_orchestration_service_cache_variable.cache_variable PLBP09X:138ed254-3444-44ad-8cc7-701d69def439