grafana_role_assignment (Resource)

Manages the entire set of assignments for a role. Assignments that aren't specified when applying this resource will be removed. Note: This resource is available only with Grafana Enterprise 9.2+.

Example Usage

resource "grafana_role" "test_role" {
  name    = "Test Role"
  uid     = "testrole"
  version = 1
  global  = true

  permissions {
    action = "org.users:add"
    scope  = "users:*"
  }
}

resource "grafana_team" "test_team" {
  name = "terraform_test_team"
}

resource "grafana_user" "test_user" {
  email    = "terraform_user@test.com"
  login    = "terraform_user@test.com"
  password = "password"
}

resource "grafana_service_account" "test_sa" {
  name = "terraform_test_sa"
  role = "Viewer"
}

resource "grafana_role_assignment" "test" {
  role_uid         = grafana_role.test_role.uid
  users            = [grafana_user.test_user.id]
  teams            = [grafana_team.test_team.id]
  service_accounts = [grafana_service_account.test_sa.id]
}

Schema

Required

Optional

Read-Only

Import

Import is supported using the following syntax:

terraform import grafana_role_assignment.name "{{ roleUID }}"
terraform import grafana_role_assignment.name "{{ orgID }}:{{ roleUID }}"