|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "grafana_data_source_permission_item Resource - terraform-provider-grafana" |
| 4 | +subcategory: "Grafana Enterprise" |
| 5 | +description: |- |
| 6 | + Manages a single permission item for a datasource. Conflicts with the "grafanadatasourcepermission" resource which manages the entire set of permissions for a datasource. |
| 7 | + * Official documentation https://grafana.com/docs/grafana/latest/administration/roles-and-permissions/access-control/ |
| 8 | + * [HTTP API](https://grafana.com/docs/grafana/latest/developers/httpapi/datasource_permissions/) |
| 9 | +--- |
| 10 | + |
| 11 | +# grafana_data_source_permission_item (Resource) |
| 12 | + |
| 13 | +Manages a single permission item for a datasource. Conflicts with the "grafana_data_source_permission" resource which manages the entire set of permissions for a datasource. |
| 14 | + * [Official documentation](https://grafana.com/docs/grafana/latest/administration/roles-and-permissions/access-control/) |
| 15 | + * [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/datasource_permissions/) |
| 16 | + |
| 17 | +## Example Usage |
| 18 | + |
| 19 | +```terraform |
| 20 | +resource "grafana_team" "team" { |
| 21 | + name = "Team Name" |
| 22 | +} |
| 23 | +
|
| 24 | +resource "grafana_data_source" "foo" { |
| 25 | + type = "cloudwatch" |
| 26 | + name = "cw-example" |
| 27 | +
|
| 28 | + json_data_encoded = jsonencode({ |
| 29 | + defaultRegion = "us-east-1" |
| 30 | + authType = "keys" |
| 31 | + }) |
| 32 | +
|
| 33 | + secure_json_data_encoded = jsonencode({ |
| 34 | + accessKey = "123" |
| 35 | + secretKey = "456" |
| 36 | + }) |
| 37 | +} |
| 38 | +
|
| 39 | +resource "grafana_user" "user" { |
| 40 | + name = "test-ds-permissions" |
| 41 | + |
| 42 | + login = "test-ds-permissions" |
| 43 | + password = "hunter2" |
| 44 | +} |
| 45 | +
|
| 46 | +resource "grafana_service_account" "sa" { |
| 47 | + name = "test-ds-permissions" |
| 48 | + role = "Viewer" |
| 49 | +} |
| 50 | +
|
| 51 | +resource "grafana_data_source_permission_item" "team" { |
| 52 | + datasource_uid = grafana_data_source.foo.uid |
| 53 | + team = grafana_team.team.id |
| 54 | + permission = "Edit" |
| 55 | +} |
| 56 | +
|
| 57 | +resource "grafana_data_source_permission_item" "user" { |
| 58 | + datasource_uid = grafana_data_source.foo.uid |
| 59 | + user = grafana_user.user.id |
| 60 | + permission = "Edit" |
| 61 | +} |
| 62 | +
|
| 63 | +resource "grafana_data_source_permission_item" "role" { |
| 64 | + datasource_uid = grafana_data_source.foo.uid |
| 65 | + built_in_role = "Viewer" |
| 66 | + permission = "Query" |
| 67 | +} |
| 68 | +
|
| 69 | +resource "grafana_data_source_permission_item" "service_account" { |
| 70 | + datasource_uid = grafana_data_source.foo.uid |
| 71 | + service_account = grafana_service_account.sa.id |
| 72 | + permission = "Query" |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +<!-- schema generated by tfplugindocs --> |
| 77 | +## Schema |
| 78 | + |
| 79 | +### Required |
| 80 | + |
| 81 | +- `datasource_uid` (String) The UID of the datasource. |
| 82 | +- `permission` (String) the permission to be assigned |
| 83 | + |
| 84 | +### Optional |
| 85 | + |
| 86 | +- `org_id` (String) The Organization ID. If not set, the Org ID defined in the provider block will be used. |
| 87 | +- `role` (String) the role onto which the permission is to be assigned |
| 88 | +- `team` (String) the team onto which the permission is to be assigned |
| 89 | +- `user` (String) the user or service account onto which the permission is to be assigned |
| 90 | + |
| 91 | +### Read-Only |
| 92 | + |
| 93 | +- `id` (String) The ID of this resource. |
| 94 | + |
| 95 | +## Import |
| 96 | + |
| 97 | +Import is supported using the following syntax: |
| 98 | + |
| 99 | +```shell |
| 100 | +terraform import grafana_data_source_permission_item.name "{{ datasourceUID }}:{{ type (role, team, or user) }}:{{ identifier }}" |
| 101 | +terraform import grafana_data_source_permission_item.name "{{ orgID }}:{{ datasourceUID }}:{{ type (role, team, or user) }}:{{ identifier }}" |
| 102 | +``` |
0 commit comments