Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana-cloud/platform/grafana-assistant/configure/terraform.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana-cloud/platform/grafana-assistant/configure/terraform/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
Manage Grafana Assistant with Terraform
Use the Grafana Terraform provider to define Assistant resources in configuration files and manage their lifecycle with Terraform. This lets you review configuration changes in version control and apply them consistently across stacks.
Choose a resource
The Grafana provider includes these Assistant resources. Follow each link for its arguments, examples, and import instructions.
| Resource | Terraform reference |
|---|---|
| Rules | grafana_assistant_rule |
| Skills | grafana_assistant_skill |
| Quickstarts | grafana_assistant_quickstart |
| MCP servers | grafana_assistant_mcp_server |
| Terms acceptance | grafana_assistant_terms_acceptance |
Before you begin
You need Terraform installed, a Grafana Cloud stack with Assistant enabled, and a Grafana service account token. Grant the service account access to the Assistant app and the permissions for the resources it manages. Refer to HTTP API requirements and the permissions on the corresponding resource page.
For user-scoped resources, the service account is the owner, not the person who created its token. Use scope = "tenant" for resources shared across the organization.
Configure the provider
Set GRAFANA_URL to your Grafana Cloud stack URL and GRAFANA_AUTH to your service account token. Use the stack URL, for example https://your-stack.grafana.net, rather than the HTTP API base path.
Create a Terraform configuration file:
terraform {
required_providers {
grafana = {
source = "grafana/grafana"
version = "~> 4.46"
}
}
}
provider "grafana" {}The provider reads the URL and token from those environment variables. For other configuration options, refer to the Grafana provider documentation.
Create an Assistant rule
Add a rule to the configuration:
resource "grafana_assistant_rule" "service_health" {
name = "Service health summaries"
rule_content = "Include request rate, error rate, and duration when summarizing service health."
scope = "tenant"
applications = ["assistant"]
}The service account needs the tenant rule permissions listed in the Rules API to create, read, update, and delete this resource.
Initialize the provider and review the proposed changes:
terraform init
terraform planRun terraform apply when you are ready to create the rule.
Manage existing resources
To bring an existing Assistant resource under Terraform management, use the import instructions in its provider reference. Keep subsequent changes in the Terraform configuration: edits through the Assistant UI or HTTP API can differ from that configuration and may be overwritten by a later Terraform apply.
Was this page helpful?
Related resources from Grafana Labs


