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

grafana.DashboardPermissionItem

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 dashboard. Conflicts with the “grafana.DashboardPermission” resource which manages the entire set of permissions for a dashboard.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as grafana from "@pulumiverse/grafana";
    
    const teamTeam = new grafana.Team("teamTeam", {});
    const userUser = new grafana.User("userUser", {
        email: "user.name@example.com",
        password: "my-password",
        login: "user.name",
    });
    const dashboard = new grafana.Dashboard("dashboard", {configJson: JSON.stringify({
        title: "My Dashboard",
        uid: "my-dashboard-uid",
    })});
    const role = new grafana.DashboardPermissionItem("role", {
        dashboardUid: dashboard.uid,
        role: "Viewer",
        permission: "View",
    });
    const userDashboardPermissionItem = new grafana.DashboardPermissionItem("userDashboardPermissionItem", {
        dashboardUid: dashboard.uid,
        user: userUser.id,
        permission: "Admin",
    });
    const teamDashboardPermissionItem = new grafana.DashboardPermissionItem("teamDashboardPermissionItem", {
        dashboardUid: dashboard.uid,
        team: teamTeam.id,
        permission: "Edit",
    });
    
    import pulumi
    import json
    import pulumiverse_grafana as grafana
    
    team_team = grafana.Team("teamTeam")
    user_user = grafana.User("userUser",
        email="user.name@example.com",
        password="my-password",
        login="user.name")
    dashboard = grafana.Dashboard("dashboard", config_json=json.dumps({
        "title": "My Dashboard",
        "uid": "my-dashboard-uid",
    }))
    role = grafana.DashboardPermissionItem("role",
        dashboard_uid=dashboard.uid,
        role="Viewer",
        permission="View")
    user_dashboard_permission_item = grafana.DashboardPermissionItem("userDashboardPermissionItem",
        dashboard_uid=dashboard.uid,
        user=user_user.id,
        permission="Admin")
    team_dashboard_permission_item = grafana.DashboardPermissionItem("teamDashboardPermissionItem",
        dashboard_uid=dashboard.uid,
        team=team_team.id,
        permission="Edit")
    
    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
    		}
    		userUser, err := grafana.NewUser(ctx, "userUser", &grafana.UserArgs{
    			Email:    pulumi.String("user.name@example.com"),
    			Password: pulumi.String("my-password"),
    			Login:    pulumi.String("user.name"),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"title": "My Dashboard",
    			"uid":   "my-dashboard-uid",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		dashboard, err := grafana.NewDashboard(ctx, "dashboard", &grafana.DashboardArgs{
    			ConfigJson: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewDashboardPermissionItem(ctx, "role", &grafana.DashboardPermissionItemArgs{
    			DashboardUid: dashboard.Uid,
    			Role:         pulumi.String("Viewer"),
    			Permission:   pulumi.String("View"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewDashboardPermissionItem(ctx, "userDashboardPermissionItem", &grafana.DashboardPermissionItemArgs{
    			DashboardUid: dashboard.Uid,
    			User:         userUser.ID(),
    			Permission:   pulumi.String("Admin"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewDashboardPermissionItem(ctx, "teamDashboardPermissionItem", &grafana.DashboardPermissionItemArgs{
    			DashboardUid: dashboard.Uid,
    			Team:         teamTeam.ID(),
    			Permission:   pulumi.String("Edit"),
    		})
    		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 userUser = new Grafana.User("userUser", new()
        {
            Email = "user.name@example.com",
            Password = "my-password",
            Login = "user.name",
        });
    
        var dashboard = new Grafana.Dashboard("dashboard", new()
        {
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["title"] = "My Dashboard",
                ["uid"] = "my-dashboard-uid",
            }),
        });
    
        var role = new Grafana.DashboardPermissionItem("role", new()
        {
            DashboardUid = dashboard.Uid,
            Role = "Viewer",
            Permission = "View",
        });
    
        var userDashboardPermissionItem = new Grafana.DashboardPermissionItem("userDashboardPermissionItem", new()
        {
            DashboardUid = dashboard.Uid,
            User = userUser.Id,
            Permission = "Admin",
        });
    
        var teamDashboardPermissionItem = new Grafana.DashboardPermissionItem("teamDashboardPermissionItem", new()
        {
            DashboardUid = dashboard.Uid,
            Team = teamTeam.Id,
            Permission = "Edit",
        });
    
    });
    
    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.User;
    import com.pulumi.grafana.UserArgs;
    import com.pulumi.grafana.Dashboard;
    import com.pulumi.grafana.DashboardArgs;
    import com.pulumi.grafana.DashboardPermissionItem;
    import com.pulumi.grafana.DashboardPermissionItemArgs;
    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 userUser = new User("userUser", UserArgs.builder()        
                .email("user.name@example.com")
                .password("my-password")
                .login("user.name")
                .build());
    
            var dashboard = new Dashboard("dashboard", DashboardArgs.builder()        
                .configJson(serializeJson(
                    jsonObject(
                        jsonProperty("title", "My Dashboard"),
                        jsonProperty("uid", "my-dashboard-uid")
                    )))
                .build());
    
            var role = new DashboardPermissionItem("role", DashboardPermissionItemArgs.builder()        
                .dashboardUid(dashboard.uid())
                .role("Viewer")
                .permission("View")
                .build());
    
            var userDashboardPermissionItem = new DashboardPermissionItem("userDashboardPermissionItem", DashboardPermissionItemArgs.builder()        
                .dashboardUid(dashboard.uid())
                .user(userUser.id())
                .permission("Admin")
                .build());
    
            var teamDashboardPermissionItem = new DashboardPermissionItem("teamDashboardPermissionItem", DashboardPermissionItemArgs.builder()        
                .dashboardUid(dashboard.uid())
                .team(teamTeam.id())
                .permission("Edit")
                .build());
    
        }
    }
    
    resources:
      teamTeam:
        type: grafana:Team
      userUser:
        type: grafana:User
        properties:
          email: user.name@example.com
          password: my-password
          login: user.name
      dashboard:
        type: grafana:Dashboard
        properties:
          configJson:
            fn::toJSON:
              title: My Dashboard
              uid: my-dashboard-uid
      role:
        type: grafana:DashboardPermissionItem
        properties:
          dashboardUid: ${dashboard.uid}
          role: Viewer
          permission: View
      userDashboardPermissionItem:
        type: grafana:DashboardPermissionItem
        properties:
          dashboardUid: ${dashboard.uid}
          user: ${userUser.id}
          permission: Admin
      teamDashboardPermissionItem:
        type: grafana:DashboardPermissionItem
        properties:
          dashboardUid: ${dashboard.uid}
          team: ${teamTeam.id}
          permission: Edit
    

    Create DashboardPermissionItem Resource

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

    Constructor syntax

    new DashboardPermissionItem(name: string, args: DashboardPermissionItemArgs, opts?: CustomResourceOptions);
    @overload
    def DashboardPermissionItem(resource_name: str,
                                args: DashboardPermissionItemArgs,
                                opts: Optional[ResourceOptions] = None)
    
    @overload
    def DashboardPermissionItem(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                dashboard_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 NewDashboardPermissionItem(ctx *Context, name string, args DashboardPermissionItemArgs, opts ...ResourceOption) (*DashboardPermissionItem, error)
    public DashboardPermissionItem(string name, DashboardPermissionItemArgs args, CustomResourceOptions? opts = null)
    public DashboardPermissionItem(String name, DashboardPermissionItemArgs args)
    public DashboardPermissionItem(String name, DashboardPermissionItemArgs args, CustomResourceOptions options)
    
    type: grafana:DashboardPermissionItem
    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 DashboardPermissionItemArgs
    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 DashboardPermissionItemArgs
    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 DashboardPermissionItemArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DashboardPermissionItemArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DashboardPermissionItemArgs
    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 dashboardPermissionItemResource = new Grafana.DashboardPermissionItem("dashboardPermissionItemResource", new()
    {
        DashboardUid = "string",
        Permission = "string",
        OrgId = "string",
        Role = "string",
        Team = "string",
        User = "string",
    });
    
    example, err := grafana.NewDashboardPermissionItem(ctx, "dashboardPermissionItemResource", &grafana.DashboardPermissionItemArgs{
    	DashboardUid: pulumi.String("string"),
    	Permission:   pulumi.String("string"),
    	OrgId:        pulumi.String("string"),
    	Role:         pulumi.String("string"),
    	Team:         pulumi.String("string"),
    	User:         pulumi.String("string"),
    })
    
    var dashboardPermissionItemResource = new DashboardPermissionItem("dashboardPermissionItemResource", DashboardPermissionItemArgs.builder()
        .dashboardUid("string")
        .permission("string")
        .orgId("string")
        .role("string")
        .team("string")
        .user("string")
        .build());
    
    dashboard_permission_item_resource = grafana.DashboardPermissionItem("dashboardPermissionItemResource",
        dashboard_uid="string",
        permission="string",
        org_id="string",
        role="string",
        team="string",
        user="string")
    
    const dashboardPermissionItemResource = new grafana.DashboardPermissionItem("dashboardPermissionItemResource", {
        dashboardUid: "string",
        permission: "string",
        orgId: "string",
        role: "string",
        team: "string",
        user: "string",
    });
    
    type: grafana:DashboardPermissionItem
    properties:
        dashboardUid: string
        orgId: string
        permission: string
        role: string
        team: string
        user: string
    

    DashboardPermissionItem 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 DashboardPermissionItem resource accepts the following input properties:

    DashboardUid string
    The UID of the dashboard.
    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
    DashboardUid string
    The UID of the dashboard.
    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
    dashboardUid String
    The UID of the dashboard.
    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
    dashboardUid string
    The UID of the dashboard.
    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
    dashboard_uid str
    The UID of the dashboard.
    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
    dashboardUid String
    The UID of the dashboard.
    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 DashboardPermissionItem 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 DashboardPermissionItem Resource

    Get an existing DashboardPermissionItem 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?: DashboardPermissionItemState, opts?: CustomResourceOptions): DashboardPermissionItem
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            dashboard_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) -> DashboardPermissionItem
    func GetDashboardPermissionItem(ctx *Context, name string, id IDInput, state *DashboardPermissionItemState, opts ...ResourceOption) (*DashboardPermissionItem, error)
    public static DashboardPermissionItem Get(string name, Input<string> id, DashboardPermissionItemState? state, CustomResourceOptions? opts = null)
    public static DashboardPermissionItem get(String name, Output<String> id, DashboardPermissionItemState 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:
    DashboardUid string
    The UID of the dashboard.
    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
    DashboardUid string
    The UID of the dashboard.
    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
    dashboardUid String
    The UID of the dashboard.
    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
    dashboardUid string
    The UID of the dashboard.
    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
    dashboard_uid str
    The UID of the dashboard.
    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
    dashboardUid String
    The UID of the dashboard.
    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/dashboardPermissionItem:DashboardPermissionItem name "{{ dashboardUID }}:{{ type (role, team, or user) }}:{{ identifier }}"
    
    $ pulumi import grafana:index/dashboardPermissionItem:DashboardPermissionItem name "{{ orgID }}:{{ dashboardUID }}:{{ 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