---
title: Manage Incident Management with Terraform
description: >-
  Use Terraform to manage Incident Management configuration, including incident
  types, property fields, responder types, notification rules, postmortem
  templates, and notification templates.
breadcrumbs: >-
  Docs > Incident Response > Incident Management > Incident Management Guides >
  Manage Incident Management with Terraform
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Manage Incident Management with Terraform

## Overview{% #overview %}

You can use Terraform to manage your Incident Management configuration through the Datadog API. This guide covers the Incident Management resources available in the [Terraform registry](https://registry.terraform.io/providers/DataDog/datadog/latest/docs) and links to the corresponding Datadog documentation for each.

Configuring incident types, fields, roles, and notification rules by hand in the UI works well for a handful of teams. It becomes harder to scale as your organization grows, for example, when standardizing configuration across hundreds of teams or migrating from another incident management tool. Terraform lets you define this configuration as code, so you can create and update it programmatically and keep it consistent across your organization.

You can also [import](https://developer.hashicorp.com/terraform/cli/import) your existing incident type, notification, and postmortem template configurations into Terraform, and reference existing configurations as Terraform [data sources](https://developer.hashicorp.com/terraform/language/data-sources).

### What you can manage with Terraform{% #what-you-can-manage-with-terraform %}

| Resource                                                          | Purpose                                                                                                                                                                                                                                                                                                                                     |
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Incident types (`datadog_incident_type`)                          | The category of incident (for example, "Security Incident" or "Customer Impacting"). Also includes the settings on the [Information](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/information.md) page, such as private incidents and incident deletion. Anchors everything else in this table. |
| Property fields (`datadog_incident_user_defined_field`)           | Structured data responders fill out on an incident, such as root cause or affected region. Also used to configure severity and status levels on the [Information](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/information.md) page.                                                            |
| Responder types (`datadog_incident_user_defined_role`)            | Custom roles beyond the built-in Incident Commander and Responder.                                                                                                                                                                                                                                                                          |
| Notification rules (`datadog_incident_notification_rule`)         | Rules that decide when and who gets notified as incidents change.                                                                                                                                                                                                                                                                           |
| Postmortem templates (`datadog_incident_postmortem_template`)     | Where and how a postmortem document is generated for an incident type.                                                                                                                                                                                                                                                                      |
| Notification templates (`datadog_incident_notification_template`) | Reusable message content for incident notifications.                                                                                                                                                                                                                                                                                        |

## Set up the Datadog Terraform provider{% #set-up-the-datadog-terraform-provider %}

If you haven't already, configure the [Datadog Terraform provider](https://docs.datadoghq.com/integrations/terraform.md) to interact with Datadog APIs through a Terraform configuration.

## Incident types{% #incident-types %}

Incident types let you apply different settings, fields, roles, and notification behavior to different classes of incidents, such as security incidents versus customer-impacting incidents. Every other resource on this page is scoped to an incident type, so define your incident types first. Use the `configuration` block on the [incident type resource](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/incident_type) to create incident types and set the toggles found on the [Information](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/information.md) page, such as incident deletion, [test incidents](https://docs.datadoghq.com/incident_response/incident_management/guides/test_incidents.md), and [private incidents](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/information.md#private-incidents-incident-visibility). Severity and status levels, also found on the [Information](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/information.md) page, are configured with the [incident user-defined field resource](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/incident_user_defined_field).

To learn how this works in Datadog, see [Incident Types](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration.md#incident-types).

## Property fields{% #property-fields %}

Property fields let responders capture structured data on an incident, for example, root cause or affected region. Use the [incident user-defined field resource](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/incident_user_defined_field) to create property fields and scope them to an incident type.

To learn how this works in Datadog, see [Property Fields](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/property_fields.md).

## Responder types{% #responder-types %}

Responder types define the roles people can be assigned during an incident. Examples include Incident Commander or a custom role like Comms Lead. Use the [incident user-defined role resource](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/incident_user_defined_role) to create custom responder types. Scope each one to an incident type.

To learn how this works in Datadog, see [Responder Types](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/responder_types.md).

## Notification rules{% #notification-rules %}

Notification rules determine when a notification fires, who it's sent to, and which template it uses. Use the [incident notification rule resource](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/incident_notification_rule) to create rules based on triggers such as incident creation or a saved change. Conditions on a rule can include severity or affected services.

To learn how this works in Datadog, see [Notification Rules](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/notification_rules.md).

## Postmortem templates{% #postmortem-templates %}

Postmortem templates control where a postmortem document is generated for an incident type. Templates standardize the content a postmortem writer is expected to populate by defining specific sections and headers in the document. Use the [incident postmortem template resource](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/incident_postmortem_template) to configure this per incident type.

To learn how this works in Datadog, see [Postmortem Templates](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/templates.md#postmortems).

## Notification templates{% #notification-templates %}

Notification templates define reusable message content for incident notifications. Use the [incident notification template resource](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/incident_notification_template) to create templates scoped to an incident type.

To learn how this works in Datadog, see [Notification Templates](https://docs.datadoghq.com/incident_response/incident_management/setup_and_configuration/templates.md#messages).

## Full configuration example{% #full-configuration-example %}

The following example combines several of these resources into one configuration:

- A `datadog_incident_type` with a `configuration` block that disables incident deletion and enables test incidents
- A `datadog_incident_user_defined_field` and `datadog_incident_user_defined_role`, both scoped to that type
- A `datadog_incident_notification_template`
- A `datadog_incident_notification_rule` that uses the template

```terraform
resource "datadog_incident_type" "customer_impacting" {
  name        = "Customer Impacting"
  description = "Incidents that impact customers"
  configuration = {
    private_incidents            = false
    private_incidents_by_default = false
    allow_workflows              = true
    allow_incident_deletion      = false
    editable_timestamps          = false
    test_incidents               = true
    create_message               = ""
    slug_source                  = "default"
  }
}

resource "datadog_incident_user_defined_field" "root_cause" {
  name          = "root_cause"
  type          = "dropdown"
  incident_type = datadog_incident_type.customer_impacting.id

  valid_value {
    display_name = "Service Bug"
    value        = "service_bug"
  }
}

resource "datadog_incident_user_defined_role" "tech_lead" {
  name          = "Tech Lead"
  incident_type = datadog_incident_type.customer_impacting.id
}

resource "datadog_incident_notification_template" "sev1_alert" {
  name          = "SEV-1 Customer Impact Template"
  subject       = "SEV-1 Incident: {{incident.title}}"
  category      = "alert"
  incident_type = datadog_incident_type.customer_impacting.id
  content       = "SEV-1 declared: {{incident.title}}. Status: {{incident.status}}."
}

resource "datadog_incident_notification_rule" "sev1_sev2_created" {
  enabled               = true
  trigger               = "incident_created_trigger"
  visibility            = "organization"
  handles               = ["@pagerduty-on-call"]
  incident_type         = datadog_incident_type.customer_impacting.id
  notification_template = datadog_incident_notification_template.sev1_alert.id

  conditions {
    field  = "severity"
    values = ["SEV-1", "SEV-2"]
  }
}
```

## Further reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Learn more about Incident Management](https://docs.datadoghq.com/incident_response/incident_management.md)
- [Using test incidents for training and testing](https://docs.datadoghq.com/incident_response/incident_management/guides/test_incidents.md)
- [Terraform provider for Datadog](https://registry.terraform.io/providers/DataDog/datadog/latest/docs)
