---
title: "Grafana resources in Terraform | Grafana Labs"
description: "How the Grafana Terraform provider connects Terraform to Grafana and the resources it supports"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

## 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](https://registry.terraform.io/providers/grafana/grafana/latest/docs) 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 ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```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 resource        | What it manages                                            |
|---------------------------|------------------------------------------------------------|
| `grafana_dashboard`       | Dashboard definitions from JSON                            |
| `grafana_folder`          | Organizational folders for dashboards and alerts           |
| `grafana_data_source`     | Connections to Prometheus, Loki, Tempo, and other backends |
| `grafana_library_panel`   | Reusable panels shared across dashboards                   |
| `grafana_organization`    | Grafana organizations (self-managed only)                  |
| `grafana_service_account` | API credentials for automated tools                        |
| `grafana_team`            | Team definitions and memberships                           |
| `grafana_slo`             | Service Level Objectives with burn rate alerting           |

## Grafana Cloud resources with Terraform

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

| Terraform resource                    | What it manages                          |
|---------------------------------------|------------------------------------------|
| `grafana_cloud_stack`                 | Grafana Cloud stack provisioning         |
| `grafana_cloud_access_policy`         | Cloud access policies and tokens         |
| `grafana_cloud_stack_service_account` | Service accounts scoped to a Cloud stack |
