docs/sources/as-code/observability-as-code/git-sync/git-sync-setup/set-up-terraform.md
{{< admonition type="note" >}}
Git Sync is now GA for Grafana Cloud, OSS and Enterprise. Refer to Usage and performance limitations to understand usage limits for the different tiers.
Contact Grafana for support or to report any issues you encounter and help us improve this feature.
{{< /admonition >}}
You can also configure Git Sync via the Grafana provisioning app platform using Terraform.
Before you begin, make sure to have the following:
{{< admonition type="note" >}} Save all of the following Terraform configuration files in the same directory. {{< /admonition >}}
Use this Terraform configuration to configure the Grafana provider with the authentication required to set up Git Sync.
Create a service account and token in Grafana. For more information refer to Service account tokens or Create and manage a Grafana Cloud stack using Terraform.
Make sure that the token has the Admin or the Provisioning:Repositories writer permission.
Create a file named main.tf and add the following:
terraform {
required_providers {
grafana = {
source = "grafana/grafana"
version = ">= 4.28.1"
}
}
}
provider "grafana" {
url = "https://<your-stack>.grafana.net/"
auth = var.grafana_service_account_token
stack_id = var.grafana_stack_id
}
Replace the following field values:
<Stack-URL> with the URL of your Grafana stack (for example, https://my-stack.grafana.net/)<Service-account-token> with the service account token that you created (or <USERNAME>:<PASSWORD> for basic auth)<Stack-ID> with the Grafana stack ID, if you are using a Grafana Cloud stack{{< admonition type="caution" >}}
The Git Sync Terraform resources are App Platform resources and talk directly to the Grafana stack's API.
Do not use Grafana Cloud provider settings in this configuration. Configure the provider with url and auth (not cloud_api_url and cloud_access_policy_token). If you're using Grafana Cloud, set stack_id to your stack ID.
{{< /admonition >}}
You need two resources for configure and manage Git Sync:
For better understanding of the required resources, refer to Git Sync key concepts.