Skip to content

Commit

Permalink
added example for lbac rules
Browse files Browse the repository at this point in the history
  • Loading branch information
eleijonmarck committed Nov 27, 2024
1 parent 692ac09 commit eb413b9
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
77 changes: 77 additions & 0 deletions docs/resources/data_source_config_lbac_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "grafana_data_source_config_lbac_rules Resource - terraform-provider-grafana"
subcategory: "Grafana Enterprise"
description: |-
Manages LBAC rules for a data source.
!> Warning: The resource is experimental and will be subject to change. This resource manages the entire LBAC rules tree, and will overwrite any existing rules.
Official documentation https://grafana.com/docs/grafana/latest/administration/data-source-management/teamlbac/[TODO: HTTP API](no api yet)
This resource requires Grafana >=11.0.0.
---

# grafana_data_source_config_lbac_rules (Resource)

Manages LBAC rules for a data source.

!> Warning: The resource is experimental and will be subject to change. This resource manages the entire LBAC rules tree, and will overwrite any existing rules.

* [Official documentation](https://grafana.com/docs/grafana/latest/administration/data-source-management/teamlbac/)
* [TODO: HTTP API](no api yet)

This resource requires Grafana >=11.0.0.

## Example Usage

```terraform
resource "grafana_team" "team" {
name = "Team Name"
}
resource "grafana_data_source" "test" {
type = "loki"
name = "loki-from-terraform"
url = "https://mylokiurl.net"
basic_auth_enabled = true
basic_auth_username = "username"
json_data_encoded = jsonencode({
authType = "default"
## basicAuthPassword = "<>"
})
}
resource "grafana_data_source_config_lbac_rules" "test_rule" {
datasource_uid = grafana_data_source.test.uid
rules = jsonencode({
"${grafana_team.team.team_uid}" = [
"{ cluster = \"dev-us-central-0\", namespace = \"hosted-grafana\" }",
"{ foo = \"qux\" }"
]
})
depends_on = [
grafana_team.test,
grafana_data_source.test
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `datasource_uid` (String) The UID of the datasource.
- `rules` (String) JSON-encoded LBAC rules for the data source. Map of team IDs to lists of rule strings.

### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
terraform import grafana_data_source_config_lbac_rules.name "{{ datasource_uid }}"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import grafana_data_source_config_lbac_rules.name "{{ datasource_uid }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
resource "grafana_team" "team" {
name = "Team Name"
}

resource "grafana_data_source" "test" {
type = "loki"
name = "loki-from-terraform"
url = "https://mylokiurl.net"
basic_auth_enabled = true
basic_auth_username = "username"

json_data_encoded = jsonencode({
authType = "default"
## basicAuthPassword = "<>"
})
}

resource "grafana_data_source_config_lbac_rules" "test_rule" {
datasource_uid = grafana_data_source.test.uid
rules = jsonencode({
"${grafana_team.team.team_uid}" = [
"{ cluster = \"dev-us-central-0\", namespace = \"hosted-grafana\" }",
"{ foo = \"qux\" }"
]
})

depends_on = [
grafana_team.test,
grafana_data_source.test
]
}

1 change: 1 addition & 0 deletions pkg/generate/postprocessing/replace_references.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var knownReferences = []string{
"grafana_data_source.org_id=grafana_organization.id",
"grafana_data_source_config.datasourceUid=grafana_data_source.uid",
"grafana_data_source_config.uid=grafana_data_source.uid",
"grafana_data_source_config_lbac_rules.datasource_uid=grafana_data_source.uid",
"grafana_data_source_permission.datasource_uid=grafana_data_source.uid",
"grafana_data_source_permission.team_id=grafana_team.id",
"grafana_data_source_permission.user_id=grafana_service_account.id",
Expand Down

0 comments on commit eb413b9

Please sign in to comment.