Skip to content

Tensho/terraform-pagerduty-service

Repository files navigation

PagerDuty Service Terraform Module

Terraform module to manage PagerDuty service resource (batteries included).

Usage

Warning

Technical PagerDuty service can't be created without a reference to an escalation policy. Make sure to create an escalation policy before creating a service.

module "example" {
  source  = "Tensho/service/pagerduty"
  version = "1.3.0"

  name                 = "Example"
  description          = "Example service managed by Terraform"
  escalation_policy_id = pagerduty_escalation_policy.example.id

  auto_resolve_timeout    = 3600
  acknowledgement_timeout = 600

  auto_pause_notifications_parameters = {
    enabled = true
    timeout = 120
  }

  alert_grouping_setting = {
    type = "content_based"

    config = {
      time_window = 300
      aggregate   = "all"
      fields      = ["summary"]
    }
  }

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

  incident_urgency_rule = {
    type = "use_support_hours"

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

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

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

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

Check out comprehensive examples in examples folder.

Features

Requirements

Name Version
terraform >= 1.7.0
pagerduty >= 3.18

Providers

Name Version
pagerduty 3.18.1

Modules

No modules.

Resources

Name Type
pagerduty_alert_grouping_setting.default resource
pagerduty_business_service.default resource
pagerduty_service.default resource
pagerduty_service_dependency.dependent resource
pagerduty_service_dependency.supporting resource
pagerduty_service_integration.cloudwatch resource
pagerduty_service_integration.datadog resource
pagerduty_service_integration.newrelic resource
pagerduty_slack_connection.default resource
pagerduty_vendor.cloudwatch data source
pagerduty_vendor.datadog data source
pagerduty_vendor.newrelic data source

Inputs

Name Description Type Default Required
acknowledgement_timeout PagerDuty service incident acknowledged-to-triggered state change time in seconds. string "null" no
alert_grouping_setting PagerDuty service alert grouping configuration.
object({
type = string,
config = object({
timeout = optional(number, 0),
aggregate = optional(string),
fields = optional(list(string)),
time_window = optional(number, 0),
})
})
null no
auto_pause_notifications_parameters PagerDuty service transient incident auto pause before triggering (AIOps add-on).
object({
enabled = bool,
timeout = number,
})
{
"enabled": false,
"timeout": null
}
no
auto_resolve_timeout PagerDuty service incident auto resolution time in seconds. string "null" no
business PagerDuty business service vs technical service switch. bool false no
cloudwatch_integration_enabled PagerDuty service AWS CloudWatch integration switch. bool false no
datadog_integration_enabled PagerDuty service DataDog integration switch. bool false no
description PagerDuty service description. string "Managed by Terraform" no
escalation_policy_id PagerDuty service escalation policy ID. string null no
incident_urgency_rule PagerDuty service incident urgency rule.
object({
type = string
urgency = optional(string)
during_support_hours = optional(object({
type = string
urgency = string
}))
outside_support_hours = optional(object({
type = string
urgency = string
}))
})
null no
name PagerDuty service name string n/a yes
newrelic_integration_enabled PagerDuty service NewRelic integration switch. bool false no
point_of_contact PagerDuty business service point fo contact. string null no
scheduled_actions PagerDuty service incident escalation actions related within support hours.
object({
type = optional(string, "urgency_change")
to_urgency = string
at = object({
type = optional(string, "named_time")
name = string
})
})
null no
service_graph PagerDuty service graph components.
object({
dependent_services = optional(list(object({
name = string
id = string
type = string
})))
supporting_services = optional(list(object({
name = string
id = string
type = string
})))
})
{
"dependent_services": [],
"supporting_services": []
}
no
slack_connection PagerDuty service Slack connection configuration.
object({
workspace_id = string,
channel_id = string,
notification_type = string,
events = list(string)
urgency = optional(string)
priorities = optional(list(string))
})
null no
support_hours PagerDuty service support hours.
object({
type = optional(string, "fixed_time_per_day")
time_zone = string
days_of_week = list(number)
start_time = string
end_time = string
})
null no
team_id PagerDuty business service owner team ID (Business/Enterprise plan). string null no

Outputs

Name Description
cloudwatch_integration_key PagerDuty service CloudWatch integration key.
datadog_integration_key PagerDuty service DataDog integration key.
newrelic_integration_key PagerDuty service NewRelic integration key.
pagerduty_service PagerDuty service.

Contributing

This project uses conventional commits.

Prerequisites

MacOS

brew install pre-commit tfswitch terraform-docs tflint
pre-commit install --install-hooks

Provider Authentication

export PAGERDUTY_SERVICE_REGION=eu
export PAGERDUTY_TOKEN=<REDACTED>
export PAGERDUTY_USER_TOKEN=$PAGERDUTY_TOKEN

Development

Business Service

cd examples/business-service
terraform init
terraform apply
terraform destroy

Technical Service

cd examples/technical-service
terraform init
terraform apply
terraform destroy

Testing

terraform test -verbose

Documentation

  • Update "Usage" section in README.md
  • Update examples in examples folder