Slide 3 of 6

Grafana resources in Terraform

The Grafana Terraform provider

Terraform uses HashiCorp Configuration Language (HCL), an open-source toolkit to define infrastructure and resources as code.

The Grafana Terraform provider is the bridge between your Terraform configuration and the Grafana API. It handles authentication, resource lifecycle management, and state tracking. You declare it in your configuration and authenticate with your Grafana instance URL and a service account token.

hcl
terraform {
  required_providers {
    grafana = {
      source  = "grafana/grafana"
      version = ">= 2.9.0"
    }
  }
}

provider "grafana" {
  url  = var.grafana_url
  auth = var.grafana_token
}

Core Grafana infrastructure resources with Terraform

The provider manages a wide range of resources. These are the some of the resources used for a Grafana instance.

Terraform resourceWhat it manages
grafana_dashboardDashboard definitions from JSON
grafana_folderOrganizational folders for dashboards and alerts
grafana_data_sourceConnections to Prometheus, Loki, Tempo, and other backends
grafana_library_panelReusable panels shared across dashboards
grafana_organizationGrafana organizations (self-managed only)
grafana_service_accountAPI credentials for automated tools
grafana_teamTeam definitions and memberships
grafana_sloService Level Objectives with burn rate alerting

Grafana Cloud resources with Terraform

For Grafana Cloud, additional resources manage stack-level configuration.

Terraform resourceWhat it manages
grafana_cloud_stackGrafana Cloud stack provisioning
grafana_cloud_access_policyCloud access policies and tokens
grafana_cloud_stack_service_accountService accounts scoped to a Cloud stack

Script

The Grafana Terraform provider is the bridge between your Terraform configuration and the Grafana API. It translates HCL resource blocks into API calls that create, update, or delete resources in your Grafana instance. You declare what you want, Terraform handles making it happen.

To use the provider, you declare it in your Terraform configuration and authenticate with your Grafana instance URL and a service account token. A service account token is an API credential that lets automated tools authenticate to Grafana without using your personal login.

The provider manages a wide range of resources. For the core Grafana instance, you can manage dashboards, folders, data sources, library panels, organizations, service accounts, teams, and SLOs. For Grafana Cloud, additional resources let you provision stacks, access policies, and stack-scoped service accounts.

This journey uses the alerting resources as the hands-on example because they demonstrate how multiple Terraform resources work together as a pipeline: rules fire, policies route, and contact points deliver.