Manages the entire set of permissions for a datasource. Permissions that aren't specified when applying this resource will be removed.
resource "grafana_team" "team" {
name = "Team Name"
}
resource "grafana_data_source" "foo" {
type = "cloudwatch"
name = "cw-example"
json_data_encoded = jsonencode({
defaultRegion = "us-east-1"
authType = "keys"
})
secure_json_data_encoded = jsonencode({
accessKey = "123"
secretKey = "456"
})
}
resource "grafana_user" "user" {
name = "test-ds-permissions"
email = "test-ds-permissions@example.com"
login = "test-ds-permissions"
password = "hunter2"
}
resource "grafana_service_account" "sa" {
name = "test-ds-permissions"
role = "Viewer"
}
resource "grafana_data_source_permission" "fooPermissions" {
datasource_uid = grafana_data_source.foo.uid
permissions {
team_id = grafana_team.team.id
permission = "Edit"
}
permissions {
user_id = grafana_user.user.id
permission = "Edit"
}
permissions {
built_in_role = "Viewer"
permission = "Query"
}
permissions {
user_id = grafana_service_account.sa.id
permission = "Query"
}
}
datasource_id
(String, Deprecated) Deprecated: Use datasource_uid
instead.datasource_uid
(String) UID of the datasource to apply permissions to.org_id
(String) The Organization ID. If not set, the Org ID defined in the provider block will be used.permissions
(Block Set) The permission items to add/update. Items that are omitted from the list will be removed. (see below for nested schema)id
(String) The ID of this resource.permissions
Required:
permission
(String) Permission to associate with item. Options: Query
, Edit
or Admin
(Admin
can only be used with Grafana v10.3.0+).Optional:
built_in_role
(String) Name of the basic role to manage permissions for. Options: Viewer
, Editor
or Admin
.team_id
(String) ID of the team to manage permissions for. Defaults to 0
.user_id
(String) ID of the user or service account to manage permissions for. Defaults to 0
.Import is supported using the following syntax:
terraform import grafana_data_source_permission.name "{{ datasourceID }}"
terraform import grafana_data_source_permission.name "{{ orgID }}:{{ datasourceID }}"