This is documentation for the next version of Grafana documentation. For the latest stable release, go to the latest version.
Set up Git Sync with Terraform
Caution
Git Sync is available in public preview for Grafana Cloud, and is an experimental feature in Grafana v12 for open source and Enterprise editions. Documentation and support is available based on the different tiers but might be limited to enablement, configuration, and some troubleshooting. No SLAs are provided.
Git Sync is under development. Refer to Usage and performance limitations for more information. Contact Grafana for support or to report any issues you encounter and help us improve this feature.
You can also configure Git Sync via the Grafana provisioning app platform using Terraform.
Before you begin
Before you begin, make sure to have the following:
- A Grafana Cloud account or an on-prem Grafana instance.
- Administrator permissions in your Grafana stack/instance.
- Terraform 1.11 or later installed on your machine. Refer to the Terraform install documentation to learn more.
Note
Save all of the following Terraform configuration files in the same directory.
Configure the Grafana provider
Use this Terraform configuration to set up the Grafana provider to provide the authentication required to configure Git Sync.
Create a service account and token in Grafana. For more information refer to Service account tokens or Creating and managing a Grafana Cloud stack using Terraform.
Make sure that the token has the Admin or the
Provisioning:Repositorieswriter permission.Create a file named
main.tfand add the following:terraform { required_providers { grafana = { source = "grafana/grafana" version = ">= 4.28.1" } } } provider "grafana" { cloud_api_url = "<STACK_URL>" stack_id = "<STACK_ID>" cloud_access_policy_token = "<SERVICE_ACCOUNT_TOKEN>" }
Replace the following field values:
STACK_URLwith the URL of your Grafana stack, for examplehttps://my-stack.grafana.net/<STACK_ID>with the Grafana stack ID, if you are using a Grafana Cloud stackSERVICE_ACCOUNT_TOKENwith the service account token that you created
Create the resources to use Git Sync
You need two resources for configure and manage Git Sync:
- The repository resource configures the Git repository to sync Grafana resources with. For examples, refer to Repository resource in the Terraform registry.
- The connection resource configures your Git provider credentials. For examples, refer to Connection resource in the Terraform registry.
For better understanding of the required resources, refer to Git Sync key concepts.



