How do you manage Grafana with Terraform?
IntermediateProductionObservability as Code, Security & Vendor Choices
Answer
The official grafana/grafana provider manages folders, dashboards, data sources, teams, permissions and Grafana-managed alerting resources. Dashboard JSON stays in the repo and is loaded with file().
resource "grafana_folder" "payments" {
title = "Payments"
}
resource "grafana_dashboard" "checkout" {
folder = grafana_folder.payments.uid
config_json = file("${path.module}/dashboards/checkout.json")
overwrite = true
}
Strip id and version from exported JSON and keep a stable uid so links survive. Use one Terraform state per Grafana instance or organisation, and a service account token stored in the CI secret store.
More on Observability as Code, Security & Vendor Choices
What does "observability as code" cover, and why insist on it?BeginnerHow do you validate Alertmanager configuration in CI?BeginnerWhat does a CI pipeline for Prometheus rules look like?IntermediateRaw dashboard JSON, Jsonnet/Grafonnet or the Grafana Foundation SDK: which do you pick?AdvancedWhat are monitoring mixins and how do you consume them?AdvancedHow do Grafana dashboards get loaded automatically in `kube-prometheus-stack`?Beginner