--- aliases: - ../../provision-alerting-resources/terraform-provisioning/ description: Create and manage alerting resources using Terraform keywords: - grafana - alerting - alerting resources - provisioning - Terraform title: Create and manage alerting resources using Terraform weight: 200 --- # Create and manage alerting resources using Terraform Use Terraform’s Grafana Provider to manage your alerting resources and provision them into your Grafana system. Terraform provider support for Grafana Alerting makes it easy to create, manage, and maintain your entire Grafana Alerting stack as code. For more information on managing your alerting resources using Terraform, refer to the [Grafana Provider](https://registry.terraform.io/providers/grafana/grafana/latest/docs) documentation. Complete the following tasks to create and manage your alerting resources using Terraform. 1. Create an API key for provisioning. 1. Configure the Terraform provider. 1. Define your alerting resources in Terraform. 1. Run `terraform apply` to provision your alerting resources. ## Before you begin - Ensure you have the grafana/grafana [Terraform provider](https://registry.terraform.io/providers/grafana/grafana/1.28.0) 1.27.0 or higher. - Ensure you are using Grafana 9.1 or higher. ## Create an API key for provisioning You can [create a normal Grafana API key](https://grafana.com/docs/grafana/latest/administration/api-keys/) to authenticate Terraform with Grafana. Most existing tooling using API keys should automatically work with the new Grafana Alerting support. There are also dedicated RBAC roles for alerting provisioning. This lets you easily authenticate as a [service account](https://grafana.com/docs/grafana/latest/administration/service-accounts/) with the minimum permissions needed to provision your Alerting infrastructure. To create an API key for provisioning, complete the following steps. 1. Create a new service account for your CI pipeline. 1. Assign the role “Access the alert rules Provisioning API.” 1. Create a new service account token. 1. Name and save the token for use in Terraform. Alternatively, you can use basic authentication. To view all the supported authentication formats, see [here](https://registry.terraform.io/providers/grafana/grafana/latest/docs#authentication). ## Configure the Terraform provider Grafana Alerting support is included as part of the [Grafana Terraform provider](https://registry.terraform.io/providers/grafana/grafana/latest/docs). The following is an example you can use to configure the Terraform provider. ```terraform terraform { required_providers { grafana = { source = "grafana/grafana" version = ">= 1.28.2" } } } provider "grafana" { url = auth = } ``` ## Provision contact points and templates Contact points connect an alerting stack to the outside world. They tell Grafana how to connect to your external systems and where to deliver notifications. There are over fifteen different [integrations](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/contact_point#optional) to choose from. To provision contact points and templates, complete the following steps. 1. Copy this code block into a .tf file on your local machine. This example creates a contact point that sends alert notifications to Slack. ```terraform resource "grafana_contact_point" "my_slack_contact_point" { name = "Send to My Slack Channel" slack { url = text = <