grafana.enterprise.DataSourcePermissionItem
Explore with Pulumi AI
Manages a single permission item for a datasource. Conflicts with the “grafana.enterprise.DataSourcePermission” resource which manages the entire set of permissions for a datasource.
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 foo = new grafana.oss.DataSource("foo", {
type: "cloudwatch",
name: "cw-example",
jsonDataEncoded: JSON.stringify({
defaultRegion: "us-east-1",
authType: "keys",
}),
secureJsonDataEncoded: JSON.stringify({
accessKey: "123",
secretKey: "456",
}),
});
const user = new grafana.oss.User("user", {
name: "test-ds-permissions",
email: "test-ds-permissions@example.com",
login: "test-ds-permissions",
password: "hunter2",
});
const sa = new grafana.oss.ServiceAccount("sa", {
name: "test-ds-permissions",
role: "Viewer",
});
const teamDataSourcePermissionItem = new grafana.enterprise.DataSourcePermissionItem("team", {
datasourceUid: foo.uid,
team: team.id,
permission: "Edit",
});
const userDataSourcePermissionItem = new grafana.enterprise.DataSourcePermissionItem("user", {
datasourceUid: foo.uid,
user: user.id,
permission: "Edit",
});
const role = new grafana.enterprise.DataSourcePermissionItem("role", {
datasourceUid: foo.uid,
role: "Viewer",
permission: "Query",
});
const serviceAccount = new grafana.enterprise.DataSourcePermissionItem("service_account", {
datasourceUid: foo.uid,
user: sa.id,
permission: "Query",
});
import pulumi
import json
import pulumiverse_grafana as grafana
team = grafana.oss.Team("team", name="Team Name")
foo = grafana.oss.DataSource("foo",
type="cloudwatch",
name="cw-example",
json_data_encoded=json.dumps({
"defaultRegion": "us-east-1",
"authType": "keys",
}),
secure_json_data_encoded=json.dumps({
"accessKey": "123",
"secretKey": "456",
}))
user = grafana.oss.User("user",
name="test-ds-permissions",
email="test-ds-permissions@example.com",
login="test-ds-permissions",
password="hunter2")
sa = grafana.oss.ServiceAccount("sa",
name="test-ds-permissions",
role="Viewer")
team_data_source_permission_item = grafana.enterprise.DataSourcePermissionItem("team",
datasource_uid=foo.uid,
team=team.id,
permission="Edit")
user_data_source_permission_item = grafana.enterprise.DataSourcePermissionItem("user",
datasource_uid=foo.uid,
user=user.id,
permission="Edit")
role = grafana.enterprise.DataSourcePermissionItem("role",
datasource_uid=foo.uid,
role="Viewer",
permission="Query")
service_account = grafana.enterprise.DataSourcePermissionItem("service_account",
datasource_uid=foo.uid,
user=sa.id,
permission="Query")
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{}{
"defaultRegion": "us-east-1",
"authType": "keys",
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
tmpJSON1, err := json.Marshal(map[string]interface{}{
"accessKey": "123",
"secretKey": "456",
})
if err != nil {
return err
}
json1 := string(tmpJSON1)
foo, err := oss.NewDataSource(ctx, "foo", &oss.DataSourceArgs{
Type: pulumi.String("cloudwatch"),
Name: pulumi.String("cw-example"),
JsonDataEncoded: pulumi.String(json0),
SecureJsonDataEncoded: pulumi.String(json1),
})
if err != nil {
return err
}
user, err := oss.NewUser(ctx, "user", &oss.UserArgs{
Name: pulumi.String("test-ds-permissions"),
Email: pulumi.String("test-ds-permissions@example.com"),
Login: pulumi.String("test-ds-permissions"),
Password: pulumi.String("hunter2"),
})
if err != nil {
return err
}
sa, err := oss.NewServiceAccount(ctx, "sa", &oss.ServiceAccountArgs{
Name: pulumi.String("test-ds-permissions"),
Role: pulumi.String("Viewer"),
})
if err != nil {
return err
}
_, err = enterprise.NewDataSourcePermissionItem(ctx, "team", &enterprise.DataSourcePermissionItemArgs{
DatasourceUid: foo.Uid,
Team: team.ID(),
Permission: pulumi.String("Edit"),
})
if err != nil {
return err
}
_, err = enterprise.NewDataSourcePermissionItem(ctx, "user", &enterprise.DataSourcePermissionItemArgs{
DatasourceUid: foo.Uid,
User: user.ID(),
Permission: pulumi.String("Edit"),
})
if err != nil {
return err
}
_, err = enterprise.NewDataSourcePermissionItem(ctx, "role", &enterprise.DataSourcePermissionItemArgs{
DatasourceUid: foo.Uid,
Role: pulumi.String("Viewer"),
Permission: pulumi.String("Query"),
})
if err != nil {
return err
}
_, err = enterprise.NewDataSourcePermissionItem(ctx, "service_account", &enterprise.DataSourcePermissionItemArgs{
DatasourceUid: foo.Uid,
User: sa.ID(),
Permission: pulumi.String("Query"),
})
if err != nil {
return err
}
return nil
})
}
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 foo = new Grafana.Oss.DataSource("foo", new()
{
Type = "cloudwatch",
Name = "cw-example",
JsonDataEncoded = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["defaultRegion"] = "us-east-1",
["authType"] = "keys",
}),
SecureJsonDataEncoded = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["accessKey"] = "123",
["secretKey"] = "456",
}),
});
var user = new Grafana.Oss.User("user", new()
{
Name = "test-ds-permissions",
Email = "test-ds-permissions@example.com",
Login = "test-ds-permissions",
Password = "hunter2",
});
var sa = new Grafana.Oss.ServiceAccount("sa", new()
{
Name = "test-ds-permissions",
Role = "Viewer",
});
var teamDataSourcePermissionItem = new Grafana.Enterprise.DataSourcePermissionItem("team", new()
{
DatasourceUid = foo.Uid,
Team = team.Id,
Permission = "Edit",
});
var userDataSourcePermissionItem = new Grafana.Enterprise.DataSourcePermissionItem("user", new()
{
DatasourceUid = foo.Uid,
User = user.Id,
Permission = "Edit",
});
var role = new Grafana.Enterprise.DataSourcePermissionItem("role", new()
{
DatasourceUid = foo.Uid,
Role = "Viewer",
Permission = "Query",
});
var serviceAccount = new Grafana.Enterprise.DataSourcePermissionItem("service_account", new()
{
DatasourceUid = foo.Uid,
User = sa.Id,
Permission = "Query",
});
});
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.oss.User;
import com.pulumi.grafana.oss.UserArgs;
import com.pulumi.grafana.oss.ServiceAccount;
import com.pulumi.grafana.oss.ServiceAccountArgs;
import com.pulumi.grafana.enterprise.DataSourcePermissionItem;
import com.pulumi.grafana.enterprise.DataSourcePermissionItemArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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 foo = new DataSource("foo", DataSourceArgs.builder()
.type("cloudwatch")
.name("cw-example")
.jsonDataEncoded(serializeJson(
jsonObject(
jsonProperty("defaultRegion", "us-east-1"),
jsonProperty("authType", "keys")
)))
.secureJsonDataEncoded(serializeJson(
jsonObject(
jsonProperty("accessKey", "123"),
jsonProperty("secretKey", "456")
)))
.build());
var user = new User("user", UserArgs.builder()
.name("test-ds-permissions")
.email("test-ds-permissions@example.com")
.login("test-ds-permissions")
.password("hunter2")
.build());
var sa = new ServiceAccount("sa", ServiceAccountArgs.builder()
.name("test-ds-permissions")
.role("Viewer")
.build());
var teamDataSourcePermissionItem = new DataSourcePermissionItem("teamDataSourcePermissionItem", DataSourcePermissionItemArgs.builder()
.datasourceUid(foo.uid())
.team(team.id())
.permission("Edit")
.build());
var userDataSourcePermissionItem = new DataSourcePermissionItem("userDataSourcePermissionItem", DataSourcePermissionItemArgs.builder()
.datasourceUid(foo.uid())
.user(user.id())
.permission("Edit")
.build());
var role = new DataSourcePermissionItem("role", DataSourcePermissionItemArgs.builder()
.datasourceUid(foo.uid())
.role("Viewer")
.permission("Query")
.build());
var serviceAccount = new DataSourcePermissionItem("serviceAccount", DataSourcePermissionItemArgs.builder()
.datasourceUid(foo.uid())
.user(sa.id())
.permission("Query")
.build());
}
}
resources:
team:
type: grafana:oss:Team
properties:
name: Team Name
foo:
type: grafana:oss:DataSource
properties:
type: cloudwatch
name: cw-example
jsonDataEncoded:
fn::toJSON:
defaultRegion: us-east-1
authType: keys
secureJsonDataEncoded:
fn::toJSON:
accessKey: '123'
secretKey: '456'
user:
type: grafana:oss:User
properties:
name: test-ds-permissions
email: test-ds-permissions@example.com
login: test-ds-permissions
password: hunter2
sa:
type: grafana:oss:ServiceAccount
properties:
name: test-ds-permissions
role: Viewer
teamDataSourcePermissionItem:
type: grafana:enterprise:DataSourcePermissionItem
name: team
properties:
datasourceUid: ${foo.uid}
team: ${team.id}
permission: Edit
userDataSourcePermissionItem:
type: grafana:enterprise:DataSourcePermissionItem
name: user
properties:
datasourceUid: ${foo.uid}
user: ${user.id}
permission: Edit
role:
type: grafana:enterprise:DataSourcePermissionItem
properties:
datasourceUid: ${foo.uid}
role: Viewer
permission: Query
serviceAccount:
type: grafana:enterprise:DataSourcePermissionItem
name: service_account
properties:
datasourceUid: ${foo.uid}
user: ${sa.id}
permission: Query
Create DataSourcePermissionItem Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DataSourcePermissionItem(name: string, args: DataSourcePermissionItemArgs, opts?: CustomResourceOptions);
@overload
def DataSourcePermissionItem(resource_name: str,
args: DataSourcePermissionItemArgs,
opts: Optional[ResourceOptions] = None)
@overload
def DataSourcePermissionItem(resource_name: str,
opts: Optional[ResourceOptions] = None,
datasource_uid: Optional[str] = None,
permission: Optional[str] = None,
org_id: Optional[str] = None,
role: Optional[str] = None,
team: Optional[str] = None,
user: Optional[str] = None)
func NewDataSourcePermissionItem(ctx *Context, name string, args DataSourcePermissionItemArgs, opts ...ResourceOption) (*DataSourcePermissionItem, error)
public DataSourcePermissionItem(string name, DataSourcePermissionItemArgs args, CustomResourceOptions? opts = null)
public DataSourcePermissionItem(String name, DataSourcePermissionItemArgs args)
public DataSourcePermissionItem(String name, DataSourcePermissionItemArgs args, CustomResourceOptions options)
type: grafana:enterprise:DataSourcePermissionItem
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args DataSourcePermissionItemArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args DataSourcePermissionItemArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args DataSourcePermissionItemArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DataSourcePermissionItemArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DataSourcePermissionItemArgs
- 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 dataSourcePermissionItemResource = new Grafana.Enterprise.DataSourcePermissionItem("dataSourcePermissionItemResource", new()
{
DatasourceUid = "string",
Permission = "string",
OrgId = "string",
Role = "string",
Team = "string",
User = "string",
});
example, err := enterprise.NewDataSourcePermissionItem(ctx, "dataSourcePermissionItemResource", &enterprise.DataSourcePermissionItemArgs{
DatasourceUid: pulumi.String("string"),
Permission: pulumi.String("string"),
OrgId: pulumi.String("string"),
Role: pulumi.String("string"),
Team: pulumi.String("string"),
User: pulumi.String("string"),
})
var dataSourcePermissionItemResource = new DataSourcePermissionItem("dataSourcePermissionItemResource", DataSourcePermissionItemArgs.builder()
.datasourceUid("string")
.permission("string")
.orgId("string")
.role("string")
.team("string")
.user("string")
.build());
data_source_permission_item_resource = grafana.enterprise.DataSourcePermissionItem("dataSourcePermissionItemResource",
datasource_uid="string",
permission="string",
org_id="string",
role="string",
team="string",
user="string")
const dataSourcePermissionItemResource = new grafana.enterprise.DataSourcePermissionItem("dataSourcePermissionItemResource", {
datasourceUid: "string",
permission: "string",
orgId: "string",
role: "string",
team: "string",
user: "string",
});
type: grafana:enterprise:DataSourcePermissionItem
properties:
datasourceUid: string
orgId: string
permission: string
role: string
team: string
user: string
DataSourcePermissionItem 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 DataSourcePermissionItem resource accepts the following input properties:
- Datasource
Uid string - The UID of the datasource.
- Permission string
- the permission to be assigned
- Org
Id string - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- Role string
- the role onto which the permission is to be assigned
- Team string
- the team onto which the permission is to be assigned
- User string
- the user or service account onto which the permission is to be assigned
- Datasource
Uid string - The UID of the datasource.
- Permission string
- the permission to be assigned
- Org
Id string - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- Role string
- the role onto which the permission is to be assigned
- Team string
- the team onto which the permission is to be assigned
- User string
- the user or service account onto which the permission is to be assigned
- datasource
Uid String - The UID of the datasource.
- permission String
- the permission to be assigned
- org
Id String - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- role String
- the role onto which the permission is to be assigned
- team String
- the team onto which the permission is to be assigned
- user String
- the user or service account onto which the permission is to be assigned
- datasource
Uid string - The UID of the datasource.
- permission string
- the permission to be assigned
- org
Id string - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- role string
- the role onto which the permission is to be assigned
- team string
- the team onto which the permission is to be assigned
- user string
- the user or service account onto which the permission is to be assigned
- datasource_
uid str - The UID of the datasource.
- permission str
- the permission to be assigned
- org_
id str - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- role str
- the role onto which the permission is to be assigned
- team str
- the team onto which the permission is to be assigned
- user str
- the user or service account onto which the permission is to be assigned
- datasource
Uid String - The UID of the datasource.
- permission String
- the permission to be assigned
- org
Id String - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- role String
- the role onto which the permission is to be assigned
- team String
- the team onto which the permission is to be assigned
- user String
- the user or service account onto which the permission is to be assigned
Outputs
All input properties are implicitly available as output properties. Additionally, the DataSourcePermissionItem 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 DataSourcePermissionItem Resource
Get an existing DataSourcePermissionItem 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?: DataSourcePermissionItemState, opts?: CustomResourceOptions): DataSourcePermissionItem
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
datasource_uid: Optional[str] = None,
org_id: Optional[str] = None,
permission: Optional[str] = None,
role: Optional[str] = None,
team: Optional[str] = None,
user: Optional[str] = None) -> DataSourcePermissionItem
func GetDataSourcePermissionItem(ctx *Context, name string, id IDInput, state *DataSourcePermissionItemState, opts ...ResourceOption) (*DataSourcePermissionItem, error)
public static DataSourcePermissionItem Get(string name, Input<string> id, DataSourcePermissionItemState? state, CustomResourceOptions? opts = null)
public static DataSourcePermissionItem get(String name, Output<String> id, DataSourcePermissionItemState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Datasource
Uid string - The UID of the datasource.
- Org
Id string - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- Permission string
- the permission to be assigned
- Role string
- the role onto which the permission is to be assigned
- Team string
- the team onto which the permission is to be assigned
- User string
- the user or service account onto which the permission is to be assigned
- Datasource
Uid string - The UID of the datasource.
- Org
Id string - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- Permission string
- the permission to be assigned
- Role string
- the role onto which the permission is to be assigned
- Team string
- the team onto which the permission is to be assigned
- User string
- the user or service account onto which the permission is to be assigned
- datasource
Uid String - The UID of the datasource.
- org
Id String - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- permission String
- the permission to be assigned
- role String
- the role onto which the permission is to be assigned
- team String
- the team onto which the permission is to be assigned
- user String
- the user or service account onto which the permission is to be assigned
- datasource
Uid string - The UID of the datasource.
- org
Id string - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- permission string
- the permission to be assigned
- role string
- the role onto which the permission is to be assigned
- team string
- the team onto which the permission is to be assigned
- user string
- the user or service account onto which the permission is to be assigned
- datasource_
uid str - The UID of the datasource.
- org_
id str - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- permission str
- the permission to be assigned
- role str
- the role onto which the permission is to be assigned
- team str
- the team onto which the permission is to be assigned
- user str
- the user or service account onto which the permission is to be assigned
- datasource
Uid String - The UID of the datasource.
- org
Id String - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- permission String
- the permission to be assigned
- role String
- the role onto which the permission is to be assigned
- team String
- the team onto which the permission is to be assigned
- user String
- the user or service account onto which the permission is to be assigned
Import
$ pulumi import grafana:enterprise/dataSourcePermissionItem:DataSourcePermissionItem name "{{ datasourceUID }}:{{ type (role, team, or user) }}:{{ identifier }}"
$ pulumi import grafana:enterprise/dataSourcePermissionItem:DataSourcePermissionItem name "{{ orgID }}:{{ datasourceUID }}:{{ type (role, team, or user) }}:{{ identifier }}"
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.