Grafana Cloud

Provision Grafana resources with Terraform

The Grafana Terraform provider provisions configuration management resources for Grafana. If you’re a Grafana administrator you can manage dashboards, data sources, plugins, alerts and collectors, add synthetic monitoring probes and checks, manage identity and access, and more, using the Terraform provider.

Note

The resources you can manage depend on the permissions of the credentials you configure in the provider. Use a service account with the roles that the resources need. For Grafana Cloud resources, use a token from an access policy with the required scopes. To learn more, refer to Roles and permissions.

Why use the Terraform provider

To manage the entire Grafana ecosystem of resources on either Grafana Cloud or OSS deployments of Grafana, the Grafana Terraform provider supports the most Grafana resources compared to other as-code solutions.

The Terraform provider is a good fit when you want to:

  • Manage everything from one configuration: Create a Grafana Cloud stack, its access policies and tokens, and the resources inside it, such as folders, data sources, dashboards, and alerts, in the same Terraform configuration.
  • Use your existing Terraform workflow: Review changes with terraform plan, keep configuration in version control, and apply changes from CI/CD pipelines such as GitHub Actions.
  • Manage Grafana alongside your infrastructure: Provision Grafana resources in the same configuration as the cloud infrastructure they monitor, for example AWS accounts and Microsoft Azure credentials for Cloud Provider Observability.
  • Use Kubernetes manifests instead of HCL: The Grafana Crossplane provider is built from the Terraform provider and supports all of its resources as Kubernetes custom resources.

To compare Terraform with the other as-code tools, refer to Choose a tool.

Terraform guides by area

The following table lists the Grafana areas and Grafana Cloud products that have a Terraform guide, what you can do with Terraform in each area, which Grafana editions support it, and where to find the guides. For the complete list of resources and data sources, refer to the Grafana provider documentation.

AreaWhat you can do with TerraformAvailabilityGuides
AlertingProvision alert rules, contact points, notification templates, mute timings, and notification policy trees, and optionally allow editing them in the Grafana UI.Cloud, Enterprise, OSSUse Terraform to provision alerting resources
Cloud Provider ObservabilityConfigure AWS accounts, Amazon CloudWatch metrics and resource metadata scrape jobs, and Microsoft Azure credentials.CloudManage Cloud Provider Observability in Grafana Cloud using Terraform
DashboardsCreate folders and manage multiple dashboards stored as JSON source code, and deploy changes with GitHub Actions.Cloud, Enterprise, OSSCreate and manage dashboards using Terraform and GitHub Actions
Fleet ManagementPreregister collectors before they’re operational, add remote attributes to registered collectors, and create configuration pipelines that can’t be edited in the Fleet Management app.CloudManaging Fleet Management in Grafana Cloud using Terraform, Terraform and Fleet Management
Frontend ObservabilityCreate the access policy and token that let the provider manage Frontend Observability resources.CloudManaging Frontend Observability in Grafana Cloud using Terraform
Git SyncCreate the connection and repository resources that synchronize a Git repository with Grafana.Cloud, Enterprise, OSSSet up Git Sync with Terraform
Grafana AssistantManage Assistant rules, skills, quickstarts, MCP servers, and terms acceptance.Cloud (refer to note)Manage Grafana Assistant with Terraform
Grafana Cloud integrationsInstall, update, and remove the dashboards and alerts of Grafana Cloud integrations.CloudInstall and manage integrations using Terraform
Grafana Cloud stacksCreate a Grafana Cloud stack with a service account and token, and add a folder, a data source, and a dashboard to it.CloudCreate and manage a Grafana Cloud stack using Terraform
IRMConnect integrations and routes, configure escalation chains and policies, define on-call schedules and shifts, and manage outgoing webhooks and personal notification rules.CloudManaging IRM on Grafana Cloud using Terraform, Infrastructure as code, Schedules as code
Knowledge GraphManage notification alerts, suppressed assertions, custom model rules, log, trace, and profile configurations, thresholds, and Prometheus rules.CloudManage Knowledge Graph in Grafana Cloud using Terraform
Machine LearningCreate forecasts, holidays, and outlier detectors, and their alert rules.CloudProvision Machine Learning resources using Terraform
PluginsInstall plugins in a Grafana Cloud stack.Cloud (refer to note)Install plugins in Grafana Cloud using Terraform
Role-based access controlSet basic roles for users and service accounts, create custom roles, and assign fixed or custom roles to users, teams, and service accounts.Cloud, EnterpriseProvisioning RBAC with Terraform
Saved queriesCreate saved queries in the query library and import existing saved queries into Terraform.Cloud, EnterpriseManage saved queries using Terraform
Secrets ManagementCreate, rotate, and manage secure values, and configure and activate the keepers that store them.CloudManage secrets in Grafana Cloud using Terraform
SLODefine SLOs, export existing SLOs as Terraform, and import them into Terraform state. Grafana generates the recording rules, dashboards, and alerts for each SLO.CloudProvision SLO resources using Terraform
WorkflowsCreate, update, and delete workflows from YAML definitions. Grafana Workflows is in public preview.CloudUse Terraform

Note

Grafana Assistant and Plugins are listed as Grafana Cloud only because of how their Terraform resources work:

  • Grafana Assistant: You can run Grafana Assistant in self-managed Grafana by connecting it to a Grafana Cloud stack, but the Terraform resources require a Grafana Cloud stack with Assistant enabled.
  • Plugins: The grafana_cloud_plugin_installation resource only works with Grafana Cloud stacks. To install plugins in self-managed Grafana, refer to Install a plugin.