1. Packages
  2. Grafana Cloud
  3. API Docs
  4. DataSourcePermissionItem
Grafana v0.5.1 published on Wednesday, Jun 12, 2024 by pulumiverse

grafana.DataSourcePermissionItem

Explore with Pulumi AI

grafana logo
Grafana v0.5.1 published on Wednesday, Jun 12, 2024 by pulumiverse

    Manages a single permission item for a datasource. Conflicts with the “grafana.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 teamTeam = new grafana.Team("teamTeam", {});
    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 userUser = new grafana.User("userUser", {
        email: "test-ds-permissions@example.com",
        login: "test-ds-permissions",
        password: "hunter2",
    });
    const sa = new grafana.ServiceAccount("sa", {role: "Viewer"});
    const teamDataSourcePermissionItem = new grafana.DataSourcePermissionItem("teamDataSourcePermissionItem", {
        datasourceUid: foo.uid,
        team: teamTeam.id,
        permission: "Edit",
    });
    const userDataSourcePermissionItem = new grafana.DataSourcePermissionItem("userDataSourcePermissionItem", {
        datasourceUid: foo.uid,
        user: userUser.id,
        permission: "Edit",
    });
    const role = new grafana.DataSourcePermissionItem("role", {
        datasourceUid: foo.uid,
        role: "Viewer",
        permission: "Query",
    });
    const serviceAccount = new grafana.DataSourcePermissionItem("serviceAccount", {
        datasourceUid: foo.uid,
        user: sa.id,
        permission: "Query",
    });
    
    import pulumi
    import json
    import pulumiverse_grafana as grafana
    
    team_team = grafana.Team("teamTeam")
    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_user = grafana.User("userUser",
        email="test-ds-permissions@example.com",
        login="test-ds-permissions",
        password="hunter2")
    sa = grafana.ServiceAccount("sa", role="Viewer")
    team_data_source_permission_item = grafana.DataSourcePermissionItem("teamDataSourcePermissionItem",
        datasource_uid=foo.uid,
        team=team_team.id,
        permission="Edit")
    user_data_source_permission_item = grafana.DataSourcePermissionItem("userDataSourcePermissionItem",
        datasource_uid=foo.uid,
        user=user_user.id,
        permission="Edit")
    role = grafana.DataSourcePermissionItem("role",
        datasource_uid=foo.uid,
        role="Viewer",
        permission="Query")
    service_account = grafana.DataSourcePermissionItem("serviceAccount",
        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"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		teamTeam, err := grafana.NewTeam(ctx, "teamTeam", 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
    		}
    		userUser, err := grafana.NewUser(ctx, "userUser", &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.NewDataSourcePermissionItem(ctx, "teamDataSourcePermissionItem", &grafana.DataSourcePermissionItemArgs{
    			DatasourceUid: foo.Uid,
    			Team:          teamTeam.ID(),
    			Permission:    pulumi.String("Edit"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewDataSourcePermissionItem(ctx, "userDataSourcePermissionItem", &grafana.DataSourcePermissionItemArgs{
    			DatasourceUid: foo.Uid,
    			User:          userUser.ID(),
    			Permission:    pulumi.String("Edit"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewDataSourcePermissionItem(ctx, "role", &grafana.DataSourcePermissionItemArgs{
    			DatasourceUid: foo.Uid,
    			Role:          pulumi.String("Viewer"),
    			Permission:    pulumi.String("Query"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewDataSourcePermissionItem(ctx, "serviceAccount", &grafana.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 teamTeam = new Grafana.Team("teamTeam");
    
        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 userUser = new Grafana.User("userUser", new()
        {
            Email = "test-ds-permissions@example.com",
            Login = "test-ds-permissions",
            Password = "hunter2",
        });
    
        var sa = new Grafana.ServiceAccount("sa", new()
        {
            Role = "Viewer",
        });
    
        var teamDataSourcePermissionItem = new Grafana.DataSourcePermissionItem("teamDataSourcePermissionItem", new()
        {
            DatasourceUid = foo.Uid,
            Team = teamTeam.Id,
            Permission = "Edit",
        });
    
        var userDataSourcePermissionItem = new Grafana.DataSourcePermissionItem("userDataSourcePermissionItem", new()
        {
            DatasourceUid = foo.Uid,
            User = userUser.Id,
            Permission = "Edit",
        });
    
        var role = new Grafana.DataSourcePermissionItem("role", new()
        {
            DatasourceUid = foo.Uid,
            Role = "Viewer",
            Permission = "Query",
        });
    
        var serviceAccount = new Grafana.DataSourcePermissionItem("serviceAccount", 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.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.DataSourcePermissionItem;
    import com.pulumi.grafana.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 teamTeam = new Team("teamTeam");
    
            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 userUser = new User("userUser", 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 teamDataSourcePermissionItem = new DataSourcePermissionItem("teamDataSourcePermissionItem", DataSourcePermissionItemArgs.builder()        
                .datasourceUid(foo.uid())
                .team(teamTeam.id())
                .permission("Edit")
                .build());
    
            var userDataSourcePermissionItem = new DataSourcePermissionItem("userDataSourcePermissionItem", DataSourcePermissionItemArgs.builder()        
                .datasourceUid(foo.uid())
                .user(userUser.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:
      teamTeam:
        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'
      userUser:
        type: grafana:User
        properties:
          email: test-ds-permissions@example.com
          login: test-ds-permissions
          password: hunter2
      sa:
        type: grafana:ServiceAccount
        properties:
          role: Viewer
      teamDataSourcePermissionItem:
        type: grafana:DataSourcePermissionItem
        properties:
          datasourceUid: ${foo.uid}
          team: ${teamTeam.id}
          permission: Edit
      userDataSourcePermissionItem:
        type: grafana:DataSourcePermissionItem
        properties:
          datasourceUid: ${foo.uid}
          user: ${userUser.id}
          permission: Edit
      role:
        type: grafana:DataSourcePermissionItem
        properties:
          datasourceUid: ${foo.uid}
          role: Viewer
          permission: Query
      serviceAccount:
        type: grafana:DataSourcePermissionItem
        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: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.

    Example

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

    var dataSourcePermissionItemResource = new Grafana.DataSourcePermissionItem("dataSourcePermissionItemResource", new()
    {
        DatasourceUid = "string",
        Permission = "string",
        OrgId = "string",
        Role = "string",
        Team = "string",
        User = "string",
    });
    
    example, err := grafana.NewDataSourcePermissionItem(ctx, "dataSourcePermissionItemResource", &grafana.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.DataSourcePermissionItem("dataSourcePermissionItemResource",
        datasource_uid="string",
        permission="string",
        org_id="string",
        role="string",
        team="string",
        user="string")
    
    const dataSourcePermissionItemResource = new grafana.DataSourcePermissionItem("dataSourcePermissionItemResource", {
        datasourceUid: "string",
        permission: "string",
        orgId: "string",
        role: "string",
        team: "string",
        user: "string",
    });
    
    type: grafana: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

    The DataSourcePermissionItem resource accepts the following input properties:

    DatasourceUid string
    The UID of the datasource.
    Permission string
    the permission to be assigned
    OrgId 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
    DatasourceUid string
    The UID of the datasource.
    Permission string
    the permission to be assigned
    OrgId 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
    datasourceUid String
    The UID of the datasource.
    permission String
    the permission to be assigned
    orgId 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
    datasourceUid string
    The UID of the datasource.
    permission string
    the permission to be assigned
    orgId 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
    datasourceUid String
    The UID of the datasource.
    permission String
    the permission to be assigned
    orgId 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.
    The following state arguments are supported:
    DatasourceUid string
    The UID of the datasource.
    OrgId 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
    DatasourceUid string
    The UID of the datasource.
    OrgId 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
    datasourceUid String
    The UID of the datasource.
    orgId 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
    datasourceUid string
    The UID of the datasource.
    orgId 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
    datasourceUid String
    The UID of the datasource.
    orgId 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:index/dataSourcePermissionItem:DataSourcePermissionItem name "{{ datasourceUID }}:{{ type (role, team, or user) }}:{{ identifier }}"
    
    $ pulumi import grafana:index/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.
    grafana logo
    Grafana v0.5.1 published on Wednesday, Jun 12, 2024 by pulumiverse