---
title: "Install plugins in Grafana Cloud using Terraform | Grafana documentation"
description: "Learn how to install plugins in Grafana Cloud using Terraform"
---

# Install plugins in Grafana Cloud using Terraform

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](/docs/grafana-cloud/introduction/find-and-use-plugins/) documentation.

## Before you begin

Before you begin, ensure you have the following:

- A Grafana Cloud account; for more information on setting up a Grafana Cloud account, refer to [Get started](/docs/grafana-cloud/get-started/).
- Terraform installed on your machine; for more information on how to install Terraform, refer to the [Terraform install documentation](https://developer.hashicorp.com/terraform/install).
- Administrator permissions in your Grafana instance; for more information on assigning Grafana RBAC roles, refer to [Assign RBAC roles](/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-control/assign-rbac-roles/).

> 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](https://registry.terraform.io/providers/grafana/grafana/latest/docs) to provide the authentication required to manage plugin resources.

1. Create a service account and token in Grafana. For more information on creating a service account and token, refer to [Service account tokens](/docs/grafana/latest/administration/service-accounts/#service-account-tokens). You can also refer to [Creating and managing a Grafana Cloud stack using Terraform](/docs/grafana-cloud/as-code/infrastructure-as-code/terraform/terraform-cloud-stack) to set up a service account and a token.
2. Make sure that the token has the following permissions:

<!--THE END-->

- `stack-plugins:read`
- `stack-plugins:write`
- `stack-plugins:delete`

Next, create a file named `main.tf` and add the following:

terraform ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```terraform
   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 created

## Create new plugin resource

Create a file named `plugins.tf` and add the following:

terraform ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```terraform
resource "grafana_cloud_plugin_installation" "grafana-clock-panel" {
  stack_slug   = "<Your-Stack-Slug>"
  slug         = "grafana-clock-panel"
  version      = "latest"
}
```

## Summary

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](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/cloud_plugin_installation).
