1. Packages
  2. Grafana Cloud
  3. API Docs
  4. enterprise
  5. DataSourceConfigLbacRules
Grafana v0.16.3 published on Monday, Apr 7, 2025 by pulumiverse

grafana.enterprise.DataSourceConfigLbacRules

Explore with Pulumi AI

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.

This resource requires Grafana >=11.5.0.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@pulumiverse/grafana";

const team = new grafana.oss.Team("team", {name: "Team Name"});
const test = new grafana.oss.DataSource("test", {
    type: "loki",
    name: "loki-from-terraform",
    url: "https://mylokiurl.net",
    basicAuthEnabled: true,
    basicAuthUsername: "username",
    jsonDataEncoded: JSON.stringify({
        authType: "default",
        basicAuthPassword: "password",
    }),
});
const testRule = new grafana.enterprise.DataSourceConfigLbacRules("test_rule", {
    datasourceUid: test.uid,
    rules: pulumi.jsonStringify(team.teamUid.apply(teamUid => {
        [teamUid]: [
            "{ cluster = \"dev-us-central-0\", namespace = \"hosted-grafana\" }",
            "{ foo = \"qux\" }",
        ],
    })),
}, {
    dependsOn: [
        team,
        test,
    ],
});
Copy
import pulumi
import json
import pulumiverse_grafana as grafana

team = grafana.oss.Team("team", name="Team Name")
test = grafana.oss.DataSource("test",
    type="loki",
    name="loki-from-terraform",
    url="https://mylokiurl.net",
    basic_auth_enabled=True,
    basic_auth_username="username",
    json_data_encoded=json.dumps({
        "authType": "default",
        "basicAuthPassword": "password",
    }))
test_rule = grafana.enterprise.DataSourceConfigLbacRules("test_rule",
    datasource_uid=test.uid,
    rules=pulumi.Output.json_dumps(team.team_uid.apply(lambda team_uid: {
        team_uid: [
            "{ cluster = \"dev-us-central-0\", namespace = \"hosted-grafana\" }",
            "{ foo = \"qux\" }",
        ],
    })),
    opts = pulumi.ResourceOptions(depends_on=[
            team,
            test,
        ]))
Copy
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/enterprise"
	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/oss"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		team, err := oss.NewTeam(ctx, "team", &oss.TeamArgs{
			Name: pulumi.String("Team Name"),
		})
		if err != nil {
			return err
		}
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"authType":          "default",
			"basicAuthPassword": "password",
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		test, err := oss.NewDataSource(ctx, "test", &oss.DataSourceArgs{
			Type:              pulumi.String("loki"),
			Name:              pulumi.String("loki-from-terraform"),
			Url:               pulumi.String("https://mylokiurl.net"),
			BasicAuthEnabled:  pulumi.Bool(true),
			BasicAuthUsername: pulumi.String("username"),
			JsonDataEncoded:   pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		_, err = enterprise.NewDataSourceConfigLbacRules(ctx, "test_rule", &enterprise.DataSourceConfigLbacRulesArgs{
			DatasourceUid: test.Uid,
			Rules: team.TeamUid.ApplyT(func(teamUid string) (pulumi.String, error) {
				var _zero pulumi.String
				tmpJSON1, err := json.Marshal(map[string][]string{
					teamUid: []string{
						"{ cluster = \"dev-us-central-0\", namespace = \"hosted-grafana\" }",
						"{ foo = \"qux\" }",
					},
				})
				if err != nil {
					return _zero, err
				}
				json1 := string(tmpJSON1)
				return pulumi.String(json1), nil
			}).(pulumi.StringOutput),
		}, pulumi.DependsOn([]pulumi.Resource{
			team,
			test,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Grafana = Pulumiverse.Grafana;

return await Deployment.RunAsync(() => 
{
    var team = new Grafana.Oss.Team("team", new()
    {
        Name = "Team Name",
    });

    var test = new Grafana.Oss.DataSource("test", new()
    {
        Type = "loki",
        Name = "loki-from-terraform",
        Url = "https://mylokiurl.net",
        BasicAuthEnabled = true,
        BasicAuthUsername = "username",
        JsonDataEncoded = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["authType"] = "default",
            ["basicAuthPassword"] = "password",
        }),
    });

    var testRule = new Grafana.Enterprise.DataSourceConfigLbacRules("test_rule", new()
    {
        DatasourceUid = test.Uid,
        Rules = Output.JsonSerialize(Output.Create(team.TeamUid.Apply(teamUid => 
        {
            { teamUid, new[]
            {
                "{ cluster = \"dev-us-central-0\", namespace = \"hosted-grafana\" }",
                "{ foo = \"qux\" }",
            } },
        }))),
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            team,
            test,
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.oss.Team;
import com.pulumi.grafana.oss.TeamArgs;
import com.pulumi.grafana.oss.DataSource;
import com.pulumi.grafana.oss.DataSourceArgs;
import com.pulumi.grafana.enterprise.DataSourceConfigLbacRules;
import com.pulumi.grafana.enterprise.DataSourceConfigLbacRulesArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var team = new Team("team", TeamArgs.builder()
            .name("Team Name")
            .build());

        var test = new DataSource("test", DataSourceArgs.builder()
            .type("loki")
            .name("loki-from-terraform")
            .url("https://mylokiurl.net")
            .basicAuthEnabled(true)
            .basicAuthUsername("username")
            .jsonDataEncoded(serializeJson(
                jsonObject(
                    jsonProperty("authType", "default"),
                    jsonProperty("basicAuthPassword", "password")
                )))
            .build());

        var testRule = new DataSourceConfigLbacRules("testRule", DataSourceConfigLbacRulesArgs.builder()
            .datasourceUid(test.uid())
            .rules(team.teamUid().applyValue(teamUid -> serializeJson(
                jsonObject(
                    jsonProperty(teamUid, jsonArray(
                        "{ cluster = \"dev-us-central-0\", namespace = \"hosted-grafana\" }", 
                        "{ foo = \"qux\" }"
                    ))
                ))))
            .build(), CustomResourceOptions.builder()
                .dependsOn(                
                    team,
                    test)
                .build());

    }
}
Copy
resources:
  team:
    type: grafana:oss:Team
    properties:
      name: Team Name
  test:
    type: grafana:oss:DataSource
    properties:
      type: loki
      name: loki-from-terraform
      url: https://mylokiurl.net
      basicAuthEnabled: true
      basicAuthUsername: username
      jsonDataEncoded:
        fn::toJSON:
          authType: default
          basicAuthPassword: password
  testRule:
    type: grafana:enterprise:DataSourceConfigLbacRules
    name: test_rule
    properties:
      datasourceUid: ${test.uid}
      rules:
        fn::toJSON:
          ${team.teamUid}:
            - '{ cluster = "dev-us-central-0", namespace = "hosted-grafana" }'
            - '{ foo = "qux" }'
    options:
      dependsOn:
        - ${team}
        - ${test}
Copy

Create DataSourceConfigLbacRules Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new DataSourceConfigLbacRules(name: string, args: DataSourceConfigLbacRulesArgs, opts?: CustomResourceOptions);
@overload
def DataSourceConfigLbacRules(resource_name: str,
                              args: DataSourceConfigLbacRulesArgs,
                              opts: Optional[ResourceOptions] = None)

@overload
def DataSourceConfigLbacRules(resource_name: str,
                              opts: Optional[ResourceOptions] = None,
                              datasource_uid: Optional[str] = None,
                              rules: Optional[str] = None)
func NewDataSourceConfigLbacRules(ctx *Context, name string, args DataSourceConfigLbacRulesArgs, opts ...ResourceOption) (*DataSourceConfigLbacRules, error)
public DataSourceConfigLbacRules(string name, DataSourceConfigLbacRulesArgs args, CustomResourceOptions? opts = null)
public DataSourceConfigLbacRules(String name, DataSourceConfigLbacRulesArgs args)
public DataSourceConfigLbacRules(String name, DataSourceConfigLbacRulesArgs args, CustomResourceOptions options)
type: grafana:enterprise:DataSourceConfigLbacRules
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. DataSourceConfigLbacRulesArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. DataSourceConfigLbacRulesArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. DataSourceConfigLbacRulesArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. DataSourceConfigLbacRulesArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. DataSourceConfigLbacRulesArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var dataSourceConfigLbacRulesResource = new Grafana.Enterprise.DataSourceConfigLbacRules("dataSourceConfigLbacRulesResource", new()
{
    DatasourceUid = "string",
    Rules = "string",
});
Copy
example, err := enterprise.NewDataSourceConfigLbacRules(ctx, "dataSourceConfigLbacRulesResource", &enterprise.DataSourceConfigLbacRulesArgs{
	DatasourceUid: pulumi.String("string"),
	Rules:         pulumi.String("string"),
})
Copy
var dataSourceConfigLbacRulesResource = new DataSourceConfigLbacRules("dataSourceConfigLbacRulesResource", DataSourceConfigLbacRulesArgs.builder()
    .datasourceUid("string")
    .rules("string")
    .build());
Copy
data_source_config_lbac_rules_resource = grafana.enterprise.DataSourceConfigLbacRules("dataSourceConfigLbacRulesResource",
    datasource_uid="string",
    rules="string")
Copy
const dataSourceConfigLbacRulesResource = new grafana.enterprise.DataSourceConfigLbacRules("dataSourceConfigLbacRulesResource", {
    datasourceUid: "string",
    rules: "string",
});
Copy
type: grafana:enterprise:DataSourceConfigLbacRules
properties:
    datasourceUid: string
    rules: string
Copy

DataSourceConfigLbacRules Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The DataSourceConfigLbacRules resource accepts the following input properties:

DatasourceUid This property is required. string
The UID of the datasource.
Rules This property is required. string
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
DatasourceUid This property is required. string
The UID of the datasource.
Rules This property is required. string
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
datasourceUid This property is required. String
The UID of the datasource.
rules This property is required. String
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
datasourceUid This property is required. string
The UID of the datasource.
rules This property is required. string
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
datasource_uid This property is required. str
The UID of the datasource.
rules This property is required. str
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
datasourceUid This property is required. String
The UID of the datasource.
rules This property is required. String
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.

Outputs

All input properties are implicitly available as output properties. Additionally, the DataSourceConfigLbacRules resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing DataSourceConfigLbacRules Resource

Get an existing DataSourceConfigLbacRules resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: DataSourceConfigLbacRulesState, opts?: CustomResourceOptions): DataSourceConfigLbacRules
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        datasource_uid: Optional[str] = None,
        rules: Optional[str] = None) -> DataSourceConfigLbacRules
func GetDataSourceConfigLbacRules(ctx *Context, name string, id IDInput, state *DataSourceConfigLbacRulesState, opts ...ResourceOption) (*DataSourceConfigLbacRules, error)
public static DataSourceConfigLbacRules Get(string name, Input<string> id, DataSourceConfigLbacRulesState? state, CustomResourceOptions? opts = null)
public static DataSourceConfigLbacRules get(String name, Output<String> id, DataSourceConfigLbacRulesState state, CustomResourceOptions options)
resources:  _:    type: grafana:enterprise:DataSourceConfigLbacRules    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
DatasourceUid string
The UID of the datasource.
Rules string
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
DatasourceUid string
The UID of the datasource.
Rules string
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
datasourceUid String
The UID of the datasource.
rules String
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
datasourceUid string
The UID of the datasource.
rules string
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
datasource_uid str
The UID of the datasource.
rules str
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.
datasourceUid String
The UID of the datasource.
rules String
JSON-encoded LBAC rules for the data source. Map of team UIDs to lists of rule strings.

Import

$ pulumi import grafana:enterprise/dataSourceConfigLbacRules:DataSourceConfigLbacRules name "{{ datasource_uid }}"
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
grafana pulumiverse/pulumi-grafana
License
Apache-2.0
Notes
This Pulumi package is based on the grafana Terraform Provider.