auth0.UserRoles
Explore with Pulumi AI
With this resource, you can manage assigned roles for a user.
!> This resource manages all the roles assigned to a user. In contrast, the auth0.UserRole
resource only appends a
role to a user. To avoid potential issues, it is recommended not to use this resource in conjunction with the
auth0.UserRole
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.UserRoles("user_roles", {
userId: user.id,
roles: [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.UserRoles("user_roles",
user_id=user.id,
roles=[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.NewUserRoles(ctx, "user_roles", &auth0.UserRolesArgs{
UserId: user.ID(),
Roles: pulumi.StringArray{
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.UserRoles("user_roles", new()
{
UserId = user.Id,
Roles = new[]
{
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.UserRoles;
import com.pulumi.auth0.UserRolesArgs;
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 UserRoles("userRoles", UserRolesArgs.builder()
.userId(user.id())
.roles(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:UserRoles
name: user_roles
properties:
userId: ${user.id}
roles:
- ${admin.id}
Create UserRoles Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new UserRoles(name: string, args: UserRolesArgs, opts?: CustomResourceOptions);
@overload
def UserRoles(resource_name: str,
args: UserRolesArgs,
opts: Optional[ResourceOptions] = None)
@overload
def UserRoles(resource_name: str,
opts: Optional[ResourceOptions] = None,
roles: Optional[Sequence[str]] = None,
user_id: Optional[str] = None)
func NewUserRoles(ctx *Context, name string, args UserRolesArgs, opts ...ResourceOption) (*UserRoles, error)
public UserRoles(string name, UserRolesArgs args, CustomResourceOptions? opts = null)
public UserRoles(String name, UserRolesArgs args)
public UserRoles(String name, UserRolesArgs args, CustomResourceOptions options)
type: auth0:UserRoles
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 UserRolesArgs
- 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 UserRolesArgs
- 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 UserRolesArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args UserRolesArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args UserRolesArgs
- 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 userRolesResource = new Auth0.UserRoles("userRolesResource", new()
{
Roles = new[]
{
"string",
},
UserId = "string",
});
example, err := auth0.NewUserRoles(ctx, "userRolesResource", &auth0.UserRolesArgs{
Roles: pulumi.StringArray{
pulumi.String("string"),
},
UserId: pulumi.String("string"),
})
var userRolesResource = new UserRoles("userRolesResource", UserRolesArgs.builder()
.roles("string")
.userId("string")
.build());
user_roles_resource = auth0.UserRoles("userRolesResource",
roles=["string"],
user_id="string")
const userRolesResource = new auth0.UserRoles("userRolesResource", {
roles: ["string"],
userId: "string",
});
type: auth0:UserRoles
properties:
roles:
- string
userId: string
UserRoles 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 UserRoles resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the UserRoles 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 UserRoles Resource
Get an existing UserRoles 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?: UserRolesState, opts?: CustomResourceOptions): UserRoles
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
roles: Optional[Sequence[str]] = None,
user_id: Optional[str] = None) -> UserRoles
func GetUserRoles(ctx *Context, name string, id IDInput, state *UserRolesState, opts ...ResourceOption) (*UserRoles, error)
public static UserRoles Get(string name, Input<string> id, UserRolesState? state, CustomResourceOptions? opts = null)
public static UserRoles get(String name, Output<String> id, UserRolesState 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.
Import
This resource can be imported using the user ID.
Example:
$ pulumi import auth0:index/userRoles:UserRoles user_roles "auth0|111111111111111111111111"
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.