pagerduty_service

A service represents something you monitor (like a web service, email service, or database service). It is a container for related incidents that associates them with escalation policies.

Example Usage

resource "pagerduty_user" "example" {
  name  = "Earline Greenholt"
  email = "125.greenholt.earline@graham.name"
}

resource "pagerduty_escalation_policy" "foo" {
  name      = "Engineering Escalation Policy"
  num_loops = 2

  rule {
    escalation_delay_in_minutes = 10

    target {
      type = "user_reference"
      id   = pagerduty_user.example.id
    }
  }
}

resource "pagerduty_service" "example" {
  name                    = "My Web App"
  auto_resolve_timeout    = 14400
  acknowledgement_timeout = 600
  escalation_policy       = pagerduty_escalation_policy.foo.id
  alert_creation          = "create_alerts_and_incidents"

  auto_pause_notifications_parameters {
    enabled = true
    timeout = 300
  }
}

Argument Reference

The following arguments are supported:

The alert_grouping_parameters block contains the following arguments:

The auto_pause_notifications_parameters block contains the following arguments:

You may specify one optional incident_urgency_rule block configuring what urgencies to use. Your PagerDuty account must have the urgencies ability to assign an incident urgency rule. The block contains the following arguments:

When using type = "use_support_hours" in incident_urgency_rule you must specify exactly one (otherwise optional) support_hours block. Your PagerDuty account must have the service_support_hours ability to assign support hours. The block contains the following arguments:

A scheduled_actions block is required when using type = "use_support_hours" in incident_urgency_rule.

The block contains the following arguments:

The at block contains the following arguments:

Note that it is currently only possible to define the scheduled action when urgency is set to high for during_support_hours and to low for outside_support_hours in incident_urgency_rule.

Below is an example for a pagerduty_service resource with incident_urgency_rules with type = "use_support_hours", support_hours and a default scheduled_action as well.

resource "pagerduty_service" "foo" {
  name                    = "bar"
  description             = "bar bar bar"
  auto_resolve_timeout    = 3600
  acknowledgement_timeout = 3600
  escalation_policy       = pagerduty_escalation_policy.foo.id

  incident_urgency_rule {
    type = "use_support_hours"

    during_support_hours {
      type    = "constant"
      urgency = "high"
    }

    outside_support_hours {
      type    = "constant"
      urgency = "low"
    }
  }

  support_hours {
    type         = "fixed_time_per_day"
    time_zone    = "America/Lima"
    start_time   = "09:00:00"
    end_time     = "17:00:00"
    days_of_week = [1, 2, 3, 4, 5]
  }

  scheduled_actions {
    type       = "urgency_change"
    to_urgency = "high"

    at {
      type = "named_time"
      name = "support_hours_start"
    }
  }
}

Attributes Reference

The following attributes are exported:

Import

Services can be imported using the id, e.g.

$ terraform import pagerduty_service.main PLBP09X