docs/sources/as-code/infrastructure-as-code/terraform/terraform-plugins.md
This guide shows you how to install plugins in Grafana Cloud using Terraform. For more information about Grafana plugins, refer to the Find and use Grafana plugins documentation.
Before you begin, ensure you have the following:
{{< admonition type="note" >}} Save all of the following Terraform configuration files in the same directory. {{< /admonition >}}
Use this Terraform configuration to set up the Grafana provider to provide the authentication required to manage plugin resources.
Create a service account and token in Grafana. For more information on creating a service account and token, refer to Service account tokens. You can also refer to Creating and managing a Grafana Cloud stack using Terraform to set up a service account and a token.
Make sure that the token has the following permissions:
stack-plugins:readstack-plugins:writestack-plugins:deleteNext, create a file named main.tf and add the following:
terraform {
required_providers {
grafana = {
source = "grafana/grafana"
version = ">= 4.5.3"
}
}
}
provider "grafana" {
cloud_api_url = "<Stack-URL>"
cloud_access_policy_token = "<Service-account-token>"
}
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 createdCreate a file named plugins.tf and add the following:
resource "grafana_cloud_plugin_installation" "grafana-clock-panel" {
stack_slug = "<Your-Stack-Slug>"
slug = "grafana-clock-panel"
version = "latest"
}
In this guide, you learned how to install a plugin in Grafana Cloud using Terraform.
To learn more about plugin installation, refer to the Grafana provider documentation.