1. Packages
  2. Auth0 Provider
  3. API Docs
  4. UserRole
Auth0 v3.8.3 published on Wednesday, Nov 6, 2024 by Pulumi

auth0.UserRole

Explore with Pulumi AI

auth0 logo
Auth0 v3.8.3 published on Wednesday, Nov 6, 2024 by Pulumi

    With this resource, you can manage assigned roles for a user.

    !> This resource appends a role to a user. In contrast, the auth0.UserRoles resource manages all the roles assigned to a user. To avoid potential issues, it is recommended not to use this resource in conjunction with the auth0.UserRoles resource when managing roles for the same user id.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as auth0 from "@pulumi/auth0";
    
    // Example:
    const admin = new auth0.Role("admin", {
        name: "admin",
        description: "Administrator",
    });
    const user = new auth0.User("user", {
        connectionName: "Username-Password-Authentication",
        username: "unique_username",
        name: "Firstname Lastname",
        email: "test@test.com",
        password: "passpass$12$12",
    });
    const userRoles = new auth0.UserRole("user_roles", {
        userId: user.id,
        roleId: admin.id,
    });
    
    import pulumi
    import pulumi_auth0 as auth0
    
    # Example:
    admin = auth0.Role("admin",
        name="admin",
        description="Administrator")
    user = auth0.User("user",
        connection_name="Username-Password-Authentication",
        username="unique_username",
        name="Firstname Lastname",
        email="test@test.com",
        password="passpass$12$12")
    user_roles = auth0.UserRole("user_roles",
        user_id=user.id,
        role_id=admin.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-auth0/sdk/v3/go/auth0"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Example:
    		admin, err := auth0.NewRole(ctx, "admin", &auth0.RoleArgs{
    			Name:        pulumi.String("admin"),
    			Description: pulumi.String("Administrator"),
    		})
    		if err != nil {
    			return err
    		}
    		user, err := auth0.NewUser(ctx, "user", &auth0.UserArgs{
    			ConnectionName: pulumi.String("Username-Password-Authentication"),
    			Username:       pulumi.String("unique_username"),
    			Name:           pulumi.String("Firstname Lastname"),
    			Email:          pulumi.String("test@test.com"),
    			Password:       pulumi.String("passpass$12$12"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = auth0.NewUserRole(ctx, "user_roles", &auth0.UserRoleArgs{
    			UserId: user.ID(),
    			RoleId: admin.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Auth0 = Pulumi.Auth0;
    
    return await Deployment.RunAsync(() => 
    {
        // Example:
        var admin = new Auth0.Role("admin", new()
        {
            Name = "admin",
            Description = "Administrator",
        });
    
        var user = new Auth0.User("user", new()
        {
            ConnectionName = "Username-Password-Authentication",
            Username = "unique_username",
            Name = "Firstname Lastname",
            Email = "test@test.com",
            Password = "passpass$12$12",
        });
    
        var userRoles = new Auth0.UserRole("user_roles", new()
        {
            UserId = user.Id,
            RoleId = admin.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.auth0.Role;
    import com.pulumi.auth0.RoleArgs;
    import com.pulumi.auth0.User;
    import com.pulumi.auth0.UserArgs;
    import com.pulumi.auth0.UserRole;
    import com.pulumi.auth0.UserRoleArgs;
    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) {
            // Example:
            var admin = new Role("admin", RoleArgs.builder()
                .name("admin")
                .description("Administrator")
                .build());
    
            var user = new User("user", UserArgs.builder()
                .connectionName("Username-Password-Authentication")
                .username("unique_username")
                .name("Firstname Lastname")
                .email("test@test.com")
                .password("passpass$12$12")
                .build());
    
            var userRoles = new UserRole("userRoles", UserRoleArgs.builder()
                .userId(user.id())
                .roleId(admin.id())
                .build());
    
        }
    }
    
    resources:
      # Example:
      admin:
        type: auth0:Role
        properties:
          name: admin
          description: Administrator
      user:
        type: auth0:User
        properties:
          connectionName: Username-Password-Authentication
          username: unique_username
          name: Firstname Lastname
          email: test@test.com
          password: passpass$12$12
      userRoles:
        type: auth0:UserRole
        name: user_roles
        properties:
          userId: ${user.id}
          roleId: ${admin.id}
    

    Create UserRole Resource

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

    Constructor syntax

    new UserRole(name: string, args: UserRoleArgs, opts?: CustomResourceOptions);
    @overload
    def UserRole(resource_name: str,
                 args: UserRoleArgs,
                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def UserRole(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 role_id: Optional[str] = None,
                 user_id: Optional[str] = None)
    func NewUserRole(ctx *Context, name string, args UserRoleArgs, opts ...ResourceOption) (*UserRole, error)
    public UserRole(string name, UserRoleArgs args, CustomResourceOptions? opts = null)
    public UserRole(String name, UserRoleArgs args)
    public UserRole(String name, UserRoleArgs args, CustomResourceOptions options)
    
    type: auth0:UserRole
    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 UserRoleArgs
    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 UserRoleArgs
    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 UserRoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args UserRoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args UserRoleArgs
    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 userRoleResource = new Auth0.UserRole("userRoleResource", new()
    {
        RoleId = "string",
        UserId = "string",
    });
    
    example, err := auth0.NewUserRole(ctx, "userRoleResource", &auth0.UserRoleArgs{
    	RoleId: pulumi.String("string"),
    	UserId: pulumi.String("string"),
    })
    
    var userRoleResource = new UserRole("userRoleResource", UserRoleArgs.builder()
        .roleId("string")
        .userId("string")
        .build());
    
    user_role_resource = auth0.UserRole("userRoleResource",
        role_id="string",
        user_id="string")
    
    const userRoleResource = new auth0.UserRole("userRoleResource", {
        roleId: "string",
        userId: "string",
    });
    
    type: auth0:UserRole
    properties:
        roleId: string
        userId: string
    

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

    RoleId string
    ID of the role assigned to the user.
    UserId string
    ID of the user.
    RoleId string
    ID of the role assigned to the user.
    UserId string
    ID of the user.
    roleId String
    ID of the role assigned to the user.
    userId String
    ID of the user.
    roleId string
    ID of the role assigned to the user.
    userId string
    ID of the user.
    role_id str
    ID of the role assigned to the user.
    user_id str
    ID of the user.
    roleId String
    ID of the role assigned to the user.
    userId String
    ID of the user.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the UserRole resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    RoleDescription string
    Description of the role.
    RoleName string
    Name of the role.
    Id string
    The provider-assigned unique ID for this managed resource.
    RoleDescription string
    Description of the role.
    RoleName string
    Name of the role.
    id String
    The provider-assigned unique ID for this managed resource.
    roleDescription String
    Description of the role.
    roleName String
    Name of the role.
    id string
    The provider-assigned unique ID for this managed resource.
    roleDescription string
    Description of the role.
    roleName string
    Name of the role.
    id str
    The provider-assigned unique ID for this managed resource.
    role_description str
    Description of the role.
    role_name str
    Name of the role.
    id String
    The provider-assigned unique ID for this managed resource.
    roleDescription String
    Description of the role.
    roleName String
    Name of the role.

    Look up Existing UserRole Resource

    Get an existing UserRole 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?: UserRoleState, opts?: CustomResourceOptions): UserRole
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            role_description: Optional[str] = None,
            role_id: Optional[str] = None,
            role_name: Optional[str] = None,
            user_id: Optional[str] = None) -> UserRole
    func GetUserRole(ctx *Context, name string, id IDInput, state *UserRoleState, opts ...ResourceOption) (*UserRole, error)
    public static UserRole Get(string name, Input<string> id, UserRoleState? state, CustomResourceOptions? opts = null)
    public static UserRole get(String name, Output<String> id, UserRoleState 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:
    RoleDescription string
    Description of the role.
    RoleId string
    ID of the role assigned to the user.
    RoleName string
    Name of the role.
    UserId string
    ID of the user.
    RoleDescription string
    Description of the role.
    RoleId string
    ID of the role assigned to the user.
    RoleName string
    Name of the role.
    UserId string
    ID of the user.
    roleDescription String
    Description of the role.
    roleId String
    ID of the role assigned to the user.
    roleName String
    Name of the role.
    userId String
    ID of the user.
    roleDescription string
    Description of the role.
    roleId string
    ID of the role assigned to the user.
    roleName string
    Name of the role.
    userId string
    ID of the user.
    role_description str
    Description of the role.
    role_id str
    ID of the role assigned to the user.
    role_name str
    Name of the role.
    user_id str
    ID of the user.
    roleDescription String
    Description of the role.
    roleId String
    ID of the role assigned to the user.
    roleName String
    Name of the role.
    userId String
    ID of the user.

    Import

    This resource can be imported by specifying the

    user ID and role ID separated by “::” (note the double colon)

    ::

    Example:

    $ pulumi import auth0:index/userRole:UserRole user_role "auth0|111111111111111111111111::role_123"
    

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

    Package Details

    Repository
    Auth0 pulumi/pulumi-auth0
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the auth0 Terraform Provider.
    auth0 logo
    Auth0 v3.8.3 published on Wednesday, Nov 6, 2024 by Pulumi