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

grafana.RoleAssignment

Explore with Pulumi AI

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

    Manages the entire set of assignments for a role. Assignments that aren’t specified when applying this resource will be removed. Note: This resource is available only with Grafana Enterprise 9.2+.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as grafana from "@pulumiverse/grafana";
    
    const testRole = new grafana.Role("testRole", {
        uid: "testrole",
        version: 1,
        global: true,
        permissions: [{
            action: "org.users:add",
            scope: "users:*",
        }],
    });
    const testTeam = new grafana.Team("testTeam", {});
    const testUser = new grafana.User("testUser", {
        email: "terraform_user@test.com",
        login: "terraform_user@test.com",
        password: "password",
    });
    const testSa = new grafana.ServiceAccount("testSa", {role: "Viewer"});
    const test = new grafana.RoleAssignment("test", {
        roleUid: testRole.uid,
        users: [testUser.id],
        teams: [testTeam.id],
        serviceAccounts: [testSa.id],
    });
    
    import pulumi
    import pulumiverse_grafana as grafana
    
    test_role = grafana.Role("testRole",
        uid="testrole",
        version=1,
        global_=True,
        permissions=[grafana.RolePermissionArgs(
            action="org.users:add",
            scope="users:*",
        )])
    test_team = grafana.Team("testTeam")
    test_user = grafana.User("testUser",
        email="terraform_user@test.com",
        login="terraform_user@test.com",
        password="password")
    test_sa = grafana.ServiceAccount("testSa", role="Viewer")
    test = grafana.RoleAssignment("test",
        role_uid=test_role.uid,
        users=[test_user.id],
        teams=[test_team.id],
        service_accounts=[test_sa.id])
    
    package main
    
    import (
    	"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 {
    		testRole, err := grafana.NewRole(ctx, "testRole", &grafana.RoleArgs{
    			Uid:     pulumi.String("testrole"),
    			Version: pulumi.Int(1),
    			Global:  pulumi.Bool(true),
    			Permissions: grafana.RolePermissionArray{
    				&grafana.RolePermissionArgs{
    					Action: pulumi.String("org.users:add"),
    					Scope:  pulumi.String("users:*"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		testTeam, err := grafana.NewTeam(ctx, "testTeam", nil)
    		if err != nil {
    			return err
    		}
    		testUser, err := grafana.NewUser(ctx, "testUser", &grafana.UserArgs{
    			Email:    pulumi.String("terraform_user@test.com"),
    			Login:    pulumi.String("terraform_user@test.com"),
    			Password: pulumi.String("password"),
    		})
    		if err != nil {
    			return err
    		}
    		testSa, err := grafana.NewServiceAccount(ctx, "testSa", &grafana.ServiceAccountArgs{
    			Role: pulumi.String("Viewer"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewRoleAssignment(ctx, "test", &grafana.RoleAssignmentArgs{
    			RoleUid: testRole.Uid,
    			Users: pulumi.IntArray{
    				testUser.ID(),
    			},
    			Teams: pulumi.StringArray{
    				testTeam.ID(),
    			},
    			ServiceAccounts: pulumi.StringArray{
    				testSa.ID(),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Grafana = Pulumiverse.Grafana;
    
    return await Deployment.RunAsync(() => 
    {
        var testRole = new Grafana.Role("testRole", new()
        {
            Uid = "testrole",
            Version = 1,
            Global = true,
            Permissions = new[]
            {
                new Grafana.Inputs.RolePermissionArgs
                {
                    Action = "org.users:add",
                    Scope = "users:*",
                },
            },
        });
    
        var testTeam = new Grafana.Team("testTeam");
    
        var testUser = new Grafana.User("testUser", new()
        {
            Email = "terraform_user@test.com",
            Login = "terraform_user@test.com",
            Password = "password",
        });
    
        var testSa = new Grafana.ServiceAccount("testSa", new()
        {
            Role = "Viewer",
        });
    
        var test = new Grafana.RoleAssignment("test", new()
        {
            RoleUid = testRole.Uid,
            Users = new[]
            {
                testUser.Id,
            },
            Teams = new[]
            {
                testTeam.Id,
            },
            ServiceAccounts = new[]
            {
                testSa.Id,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.grafana.Role;
    import com.pulumi.grafana.RoleArgs;
    import com.pulumi.grafana.inputs.RolePermissionArgs;
    import com.pulumi.grafana.Team;
    import com.pulumi.grafana.User;
    import com.pulumi.grafana.UserArgs;
    import com.pulumi.grafana.ServiceAccount;
    import com.pulumi.grafana.ServiceAccountArgs;
    import com.pulumi.grafana.RoleAssignment;
    import com.pulumi.grafana.RoleAssignmentArgs;
    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 testRole = new Role("testRole", RoleArgs.builder()        
                .uid("testrole")
                .version(1)
                .global(true)
                .permissions(RolePermissionArgs.builder()
                    .action("org.users:add")
                    .scope("users:*")
                    .build())
                .build());
    
            var testTeam = new Team("testTeam");
    
            var testUser = new User("testUser", UserArgs.builder()        
                .email("terraform_user@test.com")
                .login("terraform_user@test.com")
                .password("password")
                .build());
    
            var testSa = new ServiceAccount("testSa", ServiceAccountArgs.builder()        
                .role("Viewer")
                .build());
    
            var test = new RoleAssignment("test", RoleAssignmentArgs.builder()        
                .roleUid(testRole.uid())
                .users(testUser.id())
                .teams(testTeam.id())
                .serviceAccounts(testSa.id())
                .build());
    
        }
    }
    
    resources:
      testRole:
        type: grafana:Role
        properties:
          uid: testrole
          version: 1
          global: true
          permissions:
            - action: org.users:add
              scope: users:*
      testTeam:
        type: grafana:Team
      testUser:
        type: grafana:User
        properties:
          email: terraform_user@test.com
          login: terraform_user@test.com
          password: password
      testSa:
        type: grafana:ServiceAccount
        properties:
          role: Viewer
      test:
        type: grafana:RoleAssignment
        properties:
          roleUid: ${testRole.uid}
          users:
            - ${testUser.id}
          teams:
            - ${testTeam.id}
          serviceAccounts:
            - ${testSa.id}
    

    Create RoleAssignment Resource

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

    Constructor syntax

    new RoleAssignment(name: string, args: RoleAssignmentArgs, opts?: CustomResourceOptions);
    @overload
    def RoleAssignment(resource_name: str,
                       args: RoleAssignmentArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def RoleAssignment(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       role_uid: Optional[str] = None,
                       org_id: Optional[str] = None,
                       service_accounts: Optional[Sequence[str]] = None,
                       teams: Optional[Sequence[str]] = None,
                       users: Optional[Sequence[int]] = None)
    func NewRoleAssignment(ctx *Context, name string, args RoleAssignmentArgs, opts ...ResourceOption) (*RoleAssignment, error)
    public RoleAssignment(string name, RoleAssignmentArgs args, CustomResourceOptions? opts = null)
    public RoleAssignment(String name, RoleAssignmentArgs args)
    public RoleAssignment(String name, RoleAssignmentArgs args, CustomResourceOptions options)
    
    type: grafana:RoleAssignment
    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 RoleAssignmentArgs
    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 RoleAssignmentArgs
    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 RoleAssignmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RoleAssignmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RoleAssignmentArgs
    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 roleAssignmentResource = new Grafana.RoleAssignment("roleAssignmentResource", new()
    {
        RoleUid = "string",
        OrgId = "string",
        ServiceAccounts = new[]
        {
            "string",
        },
        Teams = new[]
        {
            "string",
        },
        Users = new[]
        {
            0,
        },
    });
    
    example, err := grafana.NewRoleAssignment(ctx, "roleAssignmentResource", &grafana.RoleAssignmentArgs{
    	RoleUid: pulumi.String("string"),
    	OrgId:   pulumi.String("string"),
    	ServiceAccounts: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Teams: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Users: pulumi.IntArray{
    		pulumi.Int(0),
    	},
    })
    
    var roleAssignmentResource = new RoleAssignment("roleAssignmentResource", RoleAssignmentArgs.builder()
        .roleUid("string")
        .orgId("string")
        .serviceAccounts("string")
        .teams("string")
        .users(0)
        .build());
    
    role_assignment_resource = grafana.RoleAssignment("roleAssignmentResource",
        role_uid="string",
        org_id="string",
        service_accounts=["string"],
        teams=["string"],
        users=[0])
    
    const roleAssignmentResource = new grafana.RoleAssignment("roleAssignmentResource", {
        roleUid: "string",
        orgId: "string",
        serviceAccounts: ["string"],
        teams: ["string"],
        users: [0],
    });
    
    type: grafana:RoleAssignment
    properties:
        orgId: string
        roleUid: string
        serviceAccounts:
            - string
        teams:
            - string
        users:
            - 0
    

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

    RoleUid string
    Grafana RBAC role UID.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ServiceAccounts List<string>
    IDs of service accounts that the role should be assigned to.
    Teams List<string>
    IDs of teams that the role should be assigned to.
    Users List<int>
    IDs of users that the role should be assigned to.
    RoleUid string
    Grafana RBAC role UID.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ServiceAccounts []string
    IDs of service accounts that the role should be assigned to.
    Teams []string
    IDs of teams that the role should be assigned to.
    Users []int
    IDs of users that the role should be assigned to.
    roleUid String
    Grafana RBAC role UID.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    serviceAccounts List<String>
    IDs of service accounts that the role should be assigned to.
    teams List<String>
    IDs of teams that the role should be assigned to.
    users List<Integer>
    IDs of users that the role should be assigned to.
    roleUid string
    Grafana RBAC role UID.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    serviceAccounts string[]
    IDs of service accounts that the role should be assigned to.
    teams string[]
    IDs of teams that the role should be assigned to.
    users number[]
    IDs of users that the role should be assigned to.
    role_uid str
    Grafana RBAC role UID.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    service_accounts Sequence[str]
    IDs of service accounts that the role should be assigned to.
    teams Sequence[str]
    IDs of teams that the role should be assigned to.
    users Sequence[int]
    IDs of users that the role should be assigned to.
    roleUid String
    Grafana RBAC role UID.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    serviceAccounts List<String>
    IDs of service accounts that the role should be assigned to.
    teams List<String>
    IDs of teams that the role should be assigned to.
    users List<Number>
    IDs of users that the role should be assigned to.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the RoleAssignment 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 RoleAssignment Resource

    Get an existing RoleAssignment 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?: RoleAssignmentState, opts?: CustomResourceOptions): RoleAssignment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            org_id: Optional[str] = None,
            role_uid: Optional[str] = None,
            service_accounts: Optional[Sequence[str]] = None,
            teams: Optional[Sequence[str]] = None,
            users: Optional[Sequence[int]] = None) -> RoleAssignment
    func GetRoleAssignment(ctx *Context, name string, id IDInput, state *RoleAssignmentState, opts ...ResourceOption) (*RoleAssignment, error)
    public static RoleAssignment Get(string name, Input<string> id, RoleAssignmentState? state, CustomResourceOptions? opts = null)
    public static RoleAssignment get(String name, Output<String> id, RoleAssignmentState 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:
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    RoleUid string
    Grafana RBAC role UID.
    ServiceAccounts List<string>
    IDs of service accounts that the role should be assigned to.
    Teams List<string>
    IDs of teams that the role should be assigned to.
    Users List<int>
    IDs of users that the role should be assigned to.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    RoleUid string
    Grafana RBAC role UID.
    ServiceAccounts []string
    IDs of service accounts that the role should be assigned to.
    Teams []string
    IDs of teams that the role should be assigned to.
    Users []int
    IDs of users that the role should be assigned to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    roleUid String
    Grafana RBAC role UID.
    serviceAccounts List<String>
    IDs of service accounts that the role should be assigned to.
    teams List<String>
    IDs of teams that the role should be assigned to.
    users List<Integer>
    IDs of users that the role should be assigned to.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    roleUid string
    Grafana RBAC role UID.
    serviceAccounts string[]
    IDs of service accounts that the role should be assigned to.
    teams string[]
    IDs of teams that the role should be assigned to.
    users number[]
    IDs of users that the role should be assigned to.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    role_uid str
    Grafana RBAC role UID.
    service_accounts Sequence[str]
    IDs of service accounts that the role should be assigned to.
    teams Sequence[str]
    IDs of teams that the role should be assigned to.
    users Sequence[int]
    IDs of users that the role should be assigned to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    roleUid String
    Grafana RBAC role UID.
    serviceAccounts List<String>
    IDs of service accounts that the role should be assigned to.
    teams List<String>
    IDs of teams that the role should be assigned to.
    users List<Number>
    IDs of users that the role should be assigned to.

    Import

    $ pulumi import grafana:index/roleAssignment:RoleAssignment name "{{ roleUID }}"
    
    $ pulumi import grafana:index/roleAssignment:RoleAssignment name "{{ orgID }}:{{ roleUID }}"
    

    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