grafana.DataSourcePermission
Explore with Pulumi AI
Manages the entire set of permissions for a datasource. Permissions that aren’t specified when applying this resource will be removed.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@pulumiverse/grafana";
const team = new grafana.Team("team", {});
const foo = new grafana.DataSource("foo", {
type: "cloudwatch",
jsonDataEncoded: JSON.stringify({
defaultRegion: "us-east-1",
authType: "keys",
}),
secureJsonDataEncoded: JSON.stringify({
accessKey: "123",
secretKey: "456",
}),
});
const user = new grafana.User("user", {
email: "test-ds-permissions@example.com",
login: "test-ds-permissions",
password: "hunter2",
});
const sa = new grafana.ServiceAccount("sa", {role: "Viewer"});
const fooPermissions = new grafana.DataSourcePermission("fooPermissions", {
datasourceUid: foo.uid,
permissions: [
{
teamId: team.id,
permission: "Edit",
},
{
userId: user.id,
permission: "Edit",
},
{
builtInRole: "Viewer",
permission: "Query",
},
{
userId: sa.id,
permission: "Query",
},
],
});
import pulumi
import json
import pulumiverse_grafana as grafana
team = grafana.Team("team")
foo = grafana.DataSource("foo",
type="cloudwatch",
json_data_encoded=json.dumps({
"defaultRegion": "us-east-1",
"authType": "keys",
}),
secure_json_data_encoded=json.dumps({
"accessKey": "123",
"secretKey": "456",
}))
user = grafana.User("user",
email="test-ds-permissions@example.com",
login="test-ds-permissions",
password="hunter2")
sa = grafana.ServiceAccount("sa", role="Viewer")
foo_permissions = grafana.DataSourcePermission("fooPermissions",
datasource_uid=foo.uid,
permissions=[
grafana.DataSourcePermissionPermissionArgs(
team_id=team.id,
permission="Edit",
),
grafana.DataSourcePermissionPermissionArgs(
user_id=user.id,
permission="Edit",
),
grafana.DataSourcePermissionPermissionArgs(
built_in_role="Viewer",
permission="Query",
),
grafana.DataSourcePermissionPermissionArgs(
user_id=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"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
team, err := grafana.NewTeam(ctx, "team", nil)
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 := grafana.NewDataSource(ctx, "foo", &grafana.DataSourceArgs{
Type: pulumi.String("cloudwatch"),
JsonDataEncoded: pulumi.String(json0),
SecureJsonDataEncoded: pulumi.String(json1),
})
if err != nil {
return err
}
user, err := grafana.NewUser(ctx, "user", &grafana.UserArgs{
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 := grafana.NewServiceAccount(ctx, "sa", &grafana.ServiceAccountArgs{
Role: pulumi.String("Viewer"),
})
if err != nil {
return err
}
_, err = grafana.NewDataSourcePermission(ctx, "fooPermissions", &grafana.DataSourcePermissionArgs{
DatasourceUid: foo.Uid,
Permissions: grafana.DataSourcePermissionPermissionArray{
&grafana.DataSourcePermissionPermissionArgs{
TeamId: team.ID(),
Permission: pulumi.String("Edit"),
},
&grafana.DataSourcePermissionPermissionArgs{
UserId: user.ID(),
Permission: pulumi.String("Edit"),
},
&grafana.DataSourcePermissionPermissionArgs{
BuiltInRole: pulumi.String("Viewer"),
Permission: pulumi.String("Query"),
},
&grafana.DataSourcePermissionPermissionArgs{
UserId: 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.Team("team");
var foo = new Grafana.DataSource("foo", new()
{
Type = "cloudwatch",
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.User("user", new()
{
Email = "test-ds-permissions@example.com",
Login = "test-ds-permissions",
Password = "hunter2",
});
var sa = new Grafana.ServiceAccount("sa", new()
{
Role = "Viewer",
});
var fooPermissions = new Grafana.DataSourcePermission("fooPermissions", new()
{
DatasourceUid = foo.Uid,
Permissions = new[]
{
new Grafana.Inputs.DataSourcePermissionPermissionArgs
{
TeamId = team.Id,
Permission = "Edit",
},
new Grafana.Inputs.DataSourcePermissionPermissionArgs
{
UserId = user.Id,
Permission = "Edit",
},
new Grafana.Inputs.DataSourcePermissionPermissionArgs
{
BuiltInRole = "Viewer",
Permission = "Query",
},
new Grafana.Inputs.DataSourcePermissionPermissionArgs
{
UserId = sa.Id,
Permission = "Query",
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.Team;
import com.pulumi.grafana.DataSource;
import com.pulumi.grafana.DataSourceArgs;
import com.pulumi.grafana.User;
import com.pulumi.grafana.UserArgs;
import com.pulumi.grafana.ServiceAccount;
import com.pulumi.grafana.ServiceAccountArgs;
import com.pulumi.grafana.DataSourcePermission;
import com.pulumi.grafana.DataSourcePermissionArgs;
import com.pulumi.grafana.inputs.DataSourcePermissionPermissionArgs;
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");
var foo = new DataSource("foo", DataSourceArgs.builder()
.type("cloudwatch")
.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()
.email("test-ds-permissions@example.com")
.login("test-ds-permissions")
.password("hunter2")
.build());
var sa = new ServiceAccount("sa", ServiceAccountArgs.builder()
.role("Viewer")
.build());
var fooPermissions = new DataSourcePermission("fooPermissions", DataSourcePermissionArgs.builder()
.datasourceUid(foo.uid())
.permissions(
DataSourcePermissionPermissionArgs.builder()
.teamId(team.id())
.permission("Edit")
.build(),
DataSourcePermissionPermissionArgs.builder()
.userId(user.id())
.permission("Edit")
.build(),
DataSourcePermissionPermissionArgs.builder()
.builtInRole("Viewer")
.permission("Query")
.build(),
DataSourcePermissionPermissionArgs.builder()
.userId(sa.id())
.permission("Query")
.build())
.build());
}
}
resources:
team:
type: grafana:Team
foo:
type: grafana:DataSource
properties:
type: cloudwatch
jsonDataEncoded:
fn::toJSON:
defaultRegion: us-east-1
authType: keys
secureJsonDataEncoded:
fn::toJSON:
accessKey: '123'
secretKey: '456'
user:
type: grafana:User
properties:
email: test-ds-permissions@example.com
login: test-ds-permissions
password: hunter2
sa:
type: grafana:ServiceAccount
properties:
role: Viewer
fooPermissions:
type: grafana:DataSourcePermission
properties:
datasourceUid: ${foo.uid}
permissions:
- teamId: ${team.id}
permission: Edit
- userId: ${user.id}
permission: Edit
- builtInRole: Viewer
permission: Query
- userId: ${sa.id}
permission: Query
Create DataSourcePermission Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DataSourcePermission(name: string, args?: DataSourcePermissionArgs, opts?: CustomResourceOptions);
@overload
def DataSourcePermission(resource_name: str,
args: Optional[DataSourcePermissionArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def DataSourcePermission(resource_name: str,
opts: Optional[ResourceOptions] = None,
datasource_id: Optional[str] = None,
datasource_uid: Optional[str] = None,
org_id: Optional[str] = None,
permissions: Optional[Sequence[DataSourcePermissionPermissionArgs]] = None)
func NewDataSourcePermission(ctx *Context, name string, args *DataSourcePermissionArgs, opts ...ResourceOption) (*DataSourcePermission, error)
public DataSourcePermission(string name, DataSourcePermissionArgs? args = null, CustomResourceOptions? opts = null)
public DataSourcePermission(String name, DataSourcePermissionArgs args)
public DataSourcePermission(String name, DataSourcePermissionArgs args, CustomResourceOptions options)
type: grafana:DataSourcePermission
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 DataSourcePermissionArgs
- 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 DataSourcePermissionArgs
- 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 DataSourcePermissionArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DataSourcePermissionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DataSourcePermissionArgs
- 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 dataSourcePermissionResource = new Grafana.DataSourcePermission("dataSourcePermissionResource", new()
{
DatasourceUid = "string",
OrgId = "string",
Permissions = new[]
{
new Grafana.Inputs.DataSourcePermissionPermissionArgs
{
Permission = "string",
BuiltInRole = "string",
TeamId = "string",
UserId = "string",
},
},
});
example, err := grafana.NewDataSourcePermission(ctx, "dataSourcePermissionResource", &grafana.DataSourcePermissionArgs{
DatasourceUid: pulumi.String("string"),
OrgId: pulumi.String("string"),
Permissions: grafana.DataSourcePermissionPermissionArray{
&grafana.DataSourcePermissionPermissionArgs{
Permission: pulumi.String("string"),
BuiltInRole: pulumi.String("string"),
TeamId: pulumi.String("string"),
UserId: pulumi.String("string"),
},
},
})
var dataSourcePermissionResource = new DataSourcePermission("dataSourcePermissionResource", DataSourcePermissionArgs.builder()
.datasourceUid("string")
.orgId("string")
.permissions(DataSourcePermissionPermissionArgs.builder()
.permission("string")
.builtInRole("string")
.teamId("string")
.userId("string")
.build())
.build());
data_source_permission_resource = grafana.DataSourcePermission("dataSourcePermissionResource",
datasource_uid="string",
org_id="string",
permissions=[grafana.DataSourcePermissionPermissionArgs(
permission="string",
built_in_role="string",
team_id="string",
user_id="string",
)])
const dataSourcePermissionResource = new grafana.DataSourcePermission("dataSourcePermissionResource", {
datasourceUid: "string",
orgId: "string",
permissions: [{
permission: "string",
builtInRole: "string",
teamId: "string",
userId: "string",
}],
});
type: grafana:DataSourcePermission
properties:
datasourceUid: string
orgId: string
permissions:
- builtInRole: string
permission: string
teamId: string
userId: string
DataSourcePermission Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The DataSourcePermission resource accepts the following input properties:
- Datasource
Id string - 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
List<Pulumiverse.
Grafana. Inputs. Data Source Permission Permission> - The permission items to add/update. Items that are omitted from the list will be removed.
- Datasource
Id string - 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
[]Data
Source Permission Permission Args - The permission items to add/update. Items that are omitted from the list will be removed.
- datasource
Id String - 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
List<Data
Source Permission Permission> - The permission items to add/update. Items that are omitted from the list will be removed.
- datasource
Id string - 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
Data
Source Permission Permission[] - The permission items to add/update. Items that are omitted from the list will be removed.
- datasource_
id str - Deprecated: Use
datasource_uid
instead. - datasource_
uid str - UID of the datasource to apply permissions to.
- org_
id str - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- permissions
Sequence[Data
Source Permission Permission Args] - The permission items to add/update. Items that are omitted from the list will be removed.
- datasource
Id String - 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 List<Property Map>
- The permission items to add/update. Items that are omitted from the list will be removed.
Outputs
All input properties are implicitly available as output properties. Additionally, the DataSourcePermission 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 DataSourcePermission Resource
Get an existing DataSourcePermission 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?: DataSourcePermissionState, opts?: CustomResourceOptions): DataSourcePermission
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
datasource_id: Optional[str] = None,
datasource_uid: Optional[str] = None,
org_id: Optional[str] = None,
permissions: Optional[Sequence[DataSourcePermissionPermissionArgs]] = None) -> DataSourcePermission
func GetDataSourcePermission(ctx *Context, name string, id IDInput, state *DataSourcePermissionState, opts ...ResourceOption) (*DataSourcePermission, error)
public static DataSourcePermission Get(string name, Input<string> id, DataSourcePermissionState? state, CustomResourceOptions? opts = null)
public static DataSourcePermission get(String name, Output<String> id, DataSourcePermissionState 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
Id string - 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
List<Pulumiverse.
Grafana. Inputs. Data Source Permission Permission> - The permission items to add/update. Items that are omitted from the list will be removed.
- Datasource
Id string - 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
[]Data
Source Permission Permission Args - The permission items to add/update. Items that are omitted from the list will be removed.
- datasource
Id String - 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
List<Data
Source Permission Permission> - The permission items to add/update. Items that are omitted from the list will be removed.
- datasource
Id string - 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
Data
Source Permission Permission[] - The permission items to add/update. Items that are omitted from the list will be removed.
- datasource_
id str - Deprecated: Use
datasource_uid
instead. - datasource_
uid str - UID of the datasource to apply permissions to.
- org_
id str - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- permissions
Sequence[Data
Source Permission Permission Args] - The permission items to add/update. Items that are omitted from the list will be removed.
- datasource
Id String - 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 List<Property Map>
- The permission items to add/update. Items that are omitted from the list will be removed.
Supporting Types
DataSourcePermissionPermission, DataSourcePermissionPermissionArgs
- Permission string
- Permission to associate with item. Options:
Query
,Edit
orAdmin
(Admin
can only be used with Grafana v10.3.0+). - Built
In stringRole - Name of the basic role to manage permissions for. Options:
Viewer
,Editor
orAdmin
. - 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
.
- Permission string
- Permission to associate with item. Options:
Query
,Edit
orAdmin
(Admin
can only be used with Grafana v10.3.0+). - Built
In stringRole - Name of the basic role to manage permissions for. Options:
Viewer
,Editor
orAdmin
. - 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
.
- permission String
- Permission to associate with item. Options:
Query
,Edit
orAdmin
(Admin
can only be used with Grafana v10.3.0+). - built
In StringRole - Name of the basic role to manage permissions for. Options:
Viewer
,Editor
orAdmin
. - 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
.
- permission string
- Permission to associate with item. Options:
Query
,Edit
orAdmin
(Admin
can only be used with Grafana v10.3.0+). - built
In stringRole - Name of the basic role to manage permissions for. Options:
Viewer
,Editor
orAdmin
. - 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
.
- permission str
- Permission to associate with item. Options:
Query
,Edit
orAdmin
(Admin
can only be used with Grafana v10.3.0+). - built_
in_ strrole - Name of the basic role to manage permissions for. Options:
Viewer
,Editor
orAdmin
. - team_
id str - ID of the team to manage permissions for. Defaults to
0
. - user_
id str - ID of the user or service account to manage permissions for. Defaults to
0
.
- permission String
- Permission to associate with item. Options:
Query
,Edit
orAdmin
(Admin
can only be used with Grafana v10.3.0+). - built
In StringRole - Name of the basic role to manage permissions for. Options:
Viewer
,Editor
orAdmin
. - 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
$ pulumi import grafana:index/dataSourcePermission:DataSourcePermission name "{{ datasourceID }}"
$ pulumi import grafana:index/dataSourcePermission:DataSourcePermission name "{{ orgID }}:{{ datasourceID }}"
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.