1. Packages
  2. Packages
  3. Redpanda Provider
  4. API Docs
  5. RoleAssignment
Viewing docs for redpanda 2.0.0
published on Wednesday, Jun 3, 2026 by redpanda-data
Viewing docs for redpanda 2.0.0
published on Wednesday, Jun 3, 2026 by redpanda-data

    Assigns an existing Redpanda role to a principal. Resource ID format: {role_name}:{principal}

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as redpanda from "@pulumi/redpanda";
    
    const example = new redpanda.ResourceGroup("example", {name: "example-resource-group"});
    const exampleNetwork = new redpanda.Network("example", {
        name: "example-network",
        resourceGroupId: example.id,
        cloudProvider: "aws",
        region: "us-west-2",
        clusterType: "dedicated",
        cidrBlock: "10.0.0.0/20",
    });
    const exampleCluster = new redpanda.Cluster("example", {
        name: "example-cluster",
        resourceGroupId: example.id,
        networkId: exampleNetwork.id,
        cloudProvider: "aws",
        region: "us-west-2",
        clusterType: "dedicated",
        connectionType: "public",
        throughputTier: "tier-1-aws-v2-arm",
        zones: [
            "us-west-2a",
            "us-west-2b",
            "us-west-2c",
        ],
    });
    const exampleUser = new redpanda.User("example", {
        name: "example-user",
        password: examplePassword,
        mechanism: "scram-sha-256",
        clusterApiUrl: exampleCluster.clusterApiUrl,
        allowDeletion: true,
    });
    const exampleRole = new redpanda.Role("example", {
        name: "example-role",
        clusterApiUrl: exampleCluster.clusterApiUrl,
        allowDeletion: true,
    });
    const exampleRoleAssignment = new redpanda.RoleAssignment("example", {
        roleName: exampleRole.name,
        principal: pulumi.interpolate`User:${exampleUser.name}`,
        clusterApiUrl: exampleCluster.clusterApiUrl,
    });
    
    import pulumi
    import pulumi_redpanda as redpanda
    
    example = redpanda.ResourceGroup("example", name="example-resource-group")
    example_network = redpanda.Network("example",
        name="example-network",
        resource_group_id=example.id,
        cloud_provider="aws",
        region="us-west-2",
        cluster_type="dedicated",
        cidr_block="10.0.0.0/20")
    example_cluster = redpanda.Cluster("example",
        name="example-cluster",
        resource_group_id=example.id,
        network_id=example_network.id,
        cloud_provider="aws",
        region="us-west-2",
        cluster_type="dedicated",
        connection_type="public",
        throughput_tier="tier-1-aws-v2-arm",
        zones=[
            "us-west-2a",
            "us-west-2b",
            "us-west-2c",
        ])
    example_user = redpanda.User("example",
        name="example-user",
        password=example_password,
        mechanism="scram-sha-256",
        cluster_api_url=example_cluster.cluster_api_url,
        allow_deletion=True)
    example_role = redpanda.Role("example",
        name="example-role",
        cluster_api_url=example_cluster.cluster_api_url,
        allow_deletion=True)
    example_role_assignment = redpanda.RoleAssignment("example",
        role_name=example_role.name,
        principal=example_user.name.apply(lambda name: f"User:{name}"),
        cluster_api_url=example_cluster.cluster_api_url)
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/redpanda/v2/redpanda"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := redpanda.NewResourceGroup(ctx, "example", &redpanda.ResourceGroupArgs{
    			Name: pulumi.String("example-resource-group"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleNetwork, err := redpanda.NewNetwork(ctx, "example", &redpanda.NetworkArgs{
    			Name:            pulumi.String("example-network"),
    			ResourceGroupId: example.ID(),
    			CloudProvider:   pulumi.String("aws"),
    			Region:          pulumi.String("us-west-2"),
    			ClusterType:     pulumi.String("dedicated"),
    			CidrBlock:       pulumi.String("10.0.0.0/20"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleCluster, err := redpanda.NewCluster(ctx, "example", &redpanda.ClusterArgs{
    			Name:            pulumi.String("example-cluster"),
    			ResourceGroupId: example.ID(),
    			NetworkId:       exampleNetwork.ID(),
    			CloudProvider:   pulumi.String("aws"),
    			Region:          pulumi.String("us-west-2"),
    			ClusterType:     pulumi.String("dedicated"),
    			ConnectionType:  pulumi.String("public"),
    			ThroughputTier:  pulumi.String("tier-1-aws-v2-arm"),
    			Zones: pulumi.StringArray{
    				pulumi.String("us-west-2a"),
    				pulumi.String("us-west-2b"),
    				pulumi.String("us-west-2c"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		exampleUser, err := redpanda.NewUser(ctx, "example", &redpanda.UserArgs{
    			Name:          pulumi.String("example-user"),
    			Password:      pulumi.Any(examplePassword),
    			Mechanism:     pulumi.String("scram-sha-256"),
    			ClusterApiUrl: exampleCluster.ClusterApiUrl,
    			AllowDeletion: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		exampleRole, err := redpanda.NewRole(ctx, "example", &redpanda.RoleArgs{
    			Name:          pulumi.String("example-role"),
    			ClusterApiUrl: exampleCluster.ClusterApiUrl,
    			AllowDeletion: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = redpanda.NewRoleAssignment(ctx, "example", &redpanda.RoleAssignmentArgs{
    			RoleName: exampleRole.Name,
    			Principal: exampleUser.Name.ApplyT(func(name string) (string, error) {
    				return fmt.Sprintf("User:%v", name), nil
    			}).(pulumi.StringOutput),
    			ClusterApiUrl: exampleCluster.ClusterApiUrl,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Redpanda = Pulumi.Redpanda;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Redpanda.ResourceGroup("example", new()
        {
            Name = "example-resource-group",
        });
    
        var exampleNetwork = new Redpanda.Network("example", new()
        {
            Name = "example-network",
            ResourceGroupId = example.Id,
            CloudProvider = "aws",
            Region = "us-west-2",
            ClusterType = "dedicated",
            CidrBlock = "10.0.0.0/20",
        });
    
        var exampleCluster = new Redpanda.Cluster("example", new()
        {
            Name = "example-cluster",
            ResourceGroupId = example.Id,
            NetworkId = exampleNetwork.Id,
            CloudProvider = "aws",
            Region = "us-west-2",
            ClusterType = "dedicated",
            ConnectionType = "public",
            ThroughputTier = "tier-1-aws-v2-arm",
            Zones = new[]
            {
                "us-west-2a",
                "us-west-2b",
                "us-west-2c",
            },
        });
    
        var exampleUser = new Redpanda.User("example", new()
        {
            Name = "example-user",
            Password = examplePassword,
            Mechanism = "scram-sha-256",
            ClusterApiUrl = exampleCluster.ClusterApiUrl,
            AllowDeletion = true,
        });
    
        var exampleRole = new Redpanda.Role("example", new()
        {
            Name = "example-role",
            ClusterApiUrl = exampleCluster.ClusterApiUrl,
            AllowDeletion = true,
        });
    
        var exampleRoleAssignment = new Redpanda.RoleAssignment("example", new()
        {
            RoleName = exampleRole.Name,
            Principal = exampleUser.Name.Apply(name => $"User:{name}"),
            ClusterApiUrl = exampleCluster.ClusterApiUrl,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.redpanda.ResourceGroup;
    import com.pulumi.redpanda.ResourceGroupArgs;
    import com.pulumi.redpanda.Network;
    import com.pulumi.redpanda.NetworkArgs;
    import com.pulumi.redpanda.Cluster;
    import com.pulumi.redpanda.ClusterArgs;
    import com.pulumi.redpanda.User;
    import com.pulumi.redpanda.UserArgs;
    import com.pulumi.redpanda.Role;
    import com.pulumi.redpanda.RoleArgs;
    import com.pulumi.redpanda.RoleAssignment;
    import com.pulumi.redpanda.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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
                .name("example-resource-group")
                .build());
    
            var exampleNetwork = new Network("exampleNetwork", NetworkArgs.builder()
                .name("example-network")
                .resourceGroupId(example.id())
                .cloudProvider("aws")
                .region("us-west-2")
                .clusterType("dedicated")
                .cidrBlock("10.0.0.0/20")
                .build());
    
            var exampleCluster = new Cluster("exampleCluster", ClusterArgs.builder()
                .name("example-cluster")
                .resourceGroupId(example.id())
                .networkId(exampleNetwork.id())
                .cloudProvider("aws")
                .region("us-west-2")
                .clusterType("dedicated")
                .connectionType("public")
                .throughputTier("tier-1-aws-v2-arm")
                .zones(            
                    "us-west-2a",
                    "us-west-2b",
                    "us-west-2c")
                .build());
    
            var exampleUser = new User("exampleUser", UserArgs.builder()
                .name("example-user")
                .password(examplePassword)
                .mechanism("scram-sha-256")
                .clusterApiUrl(exampleCluster.clusterApiUrl())
                .allowDeletion(true)
                .build());
    
            var exampleRole = new Role("exampleRole", RoleArgs.builder()
                .name("example-role")
                .clusterApiUrl(exampleCluster.clusterApiUrl())
                .allowDeletion(true)
                .build());
    
            var exampleRoleAssignment = new RoleAssignment("exampleRoleAssignment", RoleAssignmentArgs.builder()
                .roleName(exampleRole.name())
                .principal(exampleUser.name().applyValue(_name -> String.format("User:%s", _name)))
                .clusterApiUrl(exampleCluster.clusterApiUrl())
                .build());
    
        }
    }
    
    resources:
      example:
        type: redpanda:ResourceGroup
        properties:
          name: example-resource-group
      exampleNetwork:
        type: redpanda:Network
        name: example
        properties:
          name: example-network
          resourceGroupId: ${example.id}
          cloudProvider: aws
          region: us-west-2
          clusterType: dedicated
          cidrBlock: 10.0.0.0/20
      exampleCluster:
        type: redpanda:Cluster
        name: example
        properties:
          name: example-cluster
          resourceGroupId: ${example.id}
          networkId: ${exampleNetwork.id}
          cloudProvider: aws
          region: us-west-2
          clusterType: dedicated
          connectionType: public
          throughputTier: tier-1-aws-v2-arm
          zones:
            - us-west-2a
            - us-west-2b
            - us-west-2c
      exampleUser:
        type: redpanda:User
        name: example
        properties:
          name: example-user
          password: ${examplePassword}
          mechanism: scram-sha-256
          clusterApiUrl: ${exampleCluster.clusterApiUrl}
          allowDeletion: true
      exampleRole:
        type: redpanda:Role
        name: example
        properties:
          name: example-role
          clusterApiUrl: ${exampleCluster.clusterApiUrl}
          allowDeletion: true
      exampleRoleAssignment:
        type: redpanda:RoleAssignment
        name: example
        properties:
          roleName: ${exampleRole.name}
          principal: User:${exampleUser.name}
          clusterApiUrl: ${exampleCluster.clusterApiUrl}
    
    Example coming soon!
    

    Notes

    • The role must already exist before it can be assigned. Create roles using the redpanda.Role resource, or import existing roles created via rpk or Redpanda Console.
    • The principal must be specified in the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state — no prefix stripping or normalization is performed. Bare names (without a prefix) are rejected at plan time.
    • A user can have multiple role assignments simultaneously. Permissions from all assigned roles are combined.
    • Role assignments are atomic operations - you cannot update an existing assignment. To change a role assignment, delete and recreate the resource.
    • The resource uses the Redpanda gRPC SecurityService (via console endpoint) for role management operations.

    API Reference

    For more information, see:

    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,
                       cluster_api_url: Optional[str] = None,
                       principal: Optional[str] = None,
                       role_name: Optional[str] = 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: redpanda:RoleAssignment
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "redpanda_roleassignment" "name" {
        # resource properties
    }

    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 Redpanda.RoleAssignment("roleAssignmentResource", new()
    {
        ClusterApiUrl = "string",
        Principal = "string",
        RoleName = "string",
    });
    
    example, err := redpanda.NewRoleAssignment(ctx, "roleAssignmentResource", &redpanda.RoleAssignmentArgs{
    	ClusterApiUrl: pulumi.String("string"),
    	Principal:     pulumi.String("string"),
    	RoleName:      pulumi.String("string"),
    })
    
    resource "redpanda_roleassignment" "roleAssignmentResource" {
      cluster_api_url = "string"
      principal       = "string"
      role_name       = "string"
    }
    
    var roleAssignmentResource = new RoleAssignment("roleAssignmentResource", RoleAssignmentArgs.builder()
        .clusterApiUrl("string")
        .principal("string")
        .roleName("string")
        .build());
    
    role_assignment_resource = redpanda.RoleAssignment("roleAssignmentResource",
        cluster_api_url="string",
        principal="string",
        role_name="string")
    
    const roleAssignmentResource = new redpanda.RoleAssignment("roleAssignmentResource", {
        clusterApiUrl: "string",
        principal: "string",
        roleName: "string",
    });
    
    type: redpanda:RoleAssignment
    properties:
        clusterApiUrl: string
        principal: string
        roleName: string
    

    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

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The RoleAssignment resource accepts the following input properties:

    ClusterApiUrl string
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    Principal string
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    RoleName string
    The name of the role to assign
    ClusterApiUrl string
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    Principal string
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    RoleName string
    The name of the role to assign
    cluster_api_url string
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal string
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    role_name string
    The name of the role to assign
    clusterApiUrl String
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal String
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    roleName String
    The name of the role to assign
    clusterApiUrl string
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal string
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    roleName string
    The name of the role to assign
    cluster_api_url str
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal str
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    role_name str
    The name of the role to assign
    clusterApiUrl String
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal String
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    roleName String
    The name of the role to assign

    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 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,
            cluster_api_url: Optional[str] = None,
            principal: Optional[str] = None,
            role_name: Optional[str] = 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)
    resources:  _:    type: redpanda:RoleAssignment    get:      id: ${id}
    import {
      to = redpanda_roleassignment.example
      id = "${id}"
    }
    
    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:
    ClusterApiUrl string
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    Principal string
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    RoleName string
    The name of the role to assign
    ClusterApiUrl string
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    Principal string
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    RoleName string
    The name of the role to assign
    cluster_api_url string
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal string
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    role_name string
    The name of the role to assign
    clusterApiUrl String
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal String
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    roleName String
    The name of the role to assign
    clusterApiUrl string
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal string
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    roleName string
    The name of the role to assign
    cluster_api_url str
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal str
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    role_name str
    The name of the role to assign
    clusterApiUrl String
    The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster
    principal String
    The principal to assign the role to. Use the Kafka-style prefixed form: "User:<name>" for an end user or "Group:<name>" for an IdP group. The value is preserved verbatim in state.
    roleName String
    The name of the role to assign

    Import

    Role assignments can be imported using the format <role_name>:<principal>[|<cluster_api_url>]. The optional |<cluster_api_url> suffix populates cluster_api_url at import time so the next pulumi preview is clean; without it, the field stays null in state and the next plan will force a destroy+create cycle (cluster_api_url is RequiresReplace).

    $ pulumi import redpanda:index/roleAssignment:RoleAssignment example "developer:User:alice|https://api.region.redpanda.com"
    

    The principal must already be in the canonical User:<name> or Group:<name> form. Legacy state files containing a bare principal will self-heal to the canonical form on the next refresh.

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    redpanda redpanda-data/terraform-provider-redpanda
    License
    Notes
    This Pulumi package is based on the redpanda Terraform Provider.
    Viewing docs for redpanda 2.0.0
    published on Wednesday, Jun 3, 2026 by redpanda-data

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial