1. Packages
  2. Rancher2 Provider
  3. API Docs
  4. User
Rancher 2 v9.0.0 published on Wednesday, Apr 16, 2025 by Pulumi

rancher2.User

Explore with Pulumi AI

Provides a Rancher v2 User resource. This can be used to create Users for Rancher v2 environments and retrieve their information.

When a Rancher User is created, it doesn’t have a global role binding. At least, user-base global role binding in needed in order to enable user login.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as rancher2 from "@pulumi/rancher2";

// Create a new rancher2 User
const foo = new rancher2.User("foo", {
    name: "Foo user",
    username: "foo",
    password: "changeme",
    enabled: true,
    mustChangePassword: true,
});
// Create a new rancher2 global_role_binding for User
const fooGlobalRoleBinding = new rancher2.GlobalRoleBinding("foo", {
    name: "foo",
    globalRoleId: "user-base",
    userId: foo.id,
});
Copy
import pulumi
import pulumi_rancher2 as rancher2

# Create a new rancher2 User
foo = rancher2.User("foo",
    name="Foo user",
    username="foo",
    password="changeme",
    enabled=True,
    must_change_password=True)
# Create a new rancher2 global_role_binding for User
foo_global_role_binding = rancher2.GlobalRoleBinding("foo",
    name="foo",
    global_role_id="user-base",
    user_id=foo.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-rancher2/sdk/v9/go/rancher2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Create a new rancher2 User
		foo, err := rancher2.NewUser(ctx, "foo", &rancher2.UserArgs{
			Name:               pulumi.String("Foo user"),
			Username:           pulumi.String("foo"),
			Password:           pulumi.String("changeme"),
			Enabled:            pulumi.Bool(true),
			MustChangePassword: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		// Create a new rancher2 global_role_binding for User
		_, err = rancher2.NewGlobalRoleBinding(ctx, "foo", &rancher2.GlobalRoleBindingArgs{
			Name:         pulumi.String("foo"),
			GlobalRoleId: pulumi.String("user-base"),
			UserId:       foo.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Rancher2 = Pulumi.Rancher2;

return await Deployment.RunAsync(() => 
{
    // Create a new rancher2 User
    var foo = new Rancher2.User("foo", new()
    {
        Name = "Foo user",
        Username = "foo",
        Password = "changeme",
        Enabled = true,
        MustChangePassword = true,
    });

    // Create a new rancher2 global_role_binding for User
    var fooGlobalRoleBinding = new Rancher2.GlobalRoleBinding("foo", new()
    {
        Name = "foo",
        GlobalRoleId = "user-base",
        UserId = foo.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.rancher2.User;
import com.pulumi.rancher2.UserArgs;
import com.pulumi.rancher2.GlobalRoleBinding;
import com.pulumi.rancher2.GlobalRoleBindingArgs;
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) {
        // Create a new rancher2 User
        var foo = new User("foo", UserArgs.builder()
            .name("Foo user")
            .username("foo")
            .password("changeme")
            .enabled(true)
            .mustChangePassword(true)
            .build());

        // Create a new rancher2 global_role_binding for User
        var fooGlobalRoleBinding = new GlobalRoleBinding("fooGlobalRoleBinding", GlobalRoleBindingArgs.builder()
            .name("foo")
            .globalRoleId("user-base")
            .userId(foo.id())
            .build());

    }
}
Copy
resources:
  # Create a new rancher2 User
  foo:
    type: rancher2:User
    properties:
      name: Foo user
      username: foo
      password: changeme
      enabled: true
      mustChangePassword: true
  # Create a new rancher2 global_role_binding for User
  fooGlobalRoleBinding:
    type: rancher2:GlobalRoleBinding
    name: foo
    properties:
      name: foo
      globalRoleId: user-base
      userId: ${foo.id}
Copy

Create User Resource

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

Constructor syntax

new User(name: string, args: UserArgs, opts?: CustomResourceOptions);
@overload
def User(resource_name: str,
         args: UserArgs,
         opts: Optional[ResourceOptions] = None)

@overload
def User(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         password: Optional[str] = None,
         username: Optional[str] = None,
         annotations: Optional[Mapping[str, str]] = None,
         enabled: Optional[bool] = None,
         labels: Optional[Mapping[str, str]] = None,
         must_change_password: Optional[bool] = None,
         name: Optional[str] = None)
func NewUser(ctx *Context, name string, args UserArgs, opts ...ResourceOption) (*User, error)
public User(string name, UserArgs args, CustomResourceOptions? opts = null)
public User(String name, UserArgs args)
public User(String name, UserArgs args, CustomResourceOptions options)
type: rancher2:User
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. UserArgs
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 userResource = new Rancher2.User("userResource", new()
{
    Password = "string",
    Username = "string",
    Annotations = 
    {
        { "string", "string" },
    },
    Enabled = false,
    Labels = 
    {
        { "string", "string" },
    },
    MustChangePassword = false,
    Name = "string",
});
Copy
example, err := rancher2.NewUser(ctx, "userResource", &rancher2.UserArgs{
	Password: pulumi.String("string"),
	Username: pulumi.String("string"),
	Annotations: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	Enabled: pulumi.Bool(false),
	Labels: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	MustChangePassword: pulumi.Bool(false),
	Name:               pulumi.String("string"),
})
Copy
var userResource = new User("userResource", UserArgs.builder()
    .password("string")
    .username("string")
    .annotations(Map.of("string", "string"))
    .enabled(false)
    .labels(Map.of("string", "string"))
    .mustChangePassword(false)
    .name("string")
    .build());
Copy
user_resource = rancher2.User("userResource",
    password="string",
    username="string",
    annotations={
        "string": "string",
    },
    enabled=False,
    labels={
        "string": "string",
    },
    must_change_password=False,
    name="string")
Copy
const userResource = new rancher2.User("userResource", {
    password: "string",
    username: "string",
    annotations: {
        string: "string",
    },
    enabled: false,
    labels: {
        string: "string",
    },
    mustChangePassword: false,
    name: "string",
});
Copy
type: rancher2:User
properties:
    annotations:
        string: string
    enabled: false
    labels:
        string: string
    mustChangePassword: false
    name: string
    password: string
    username: string
Copy

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

Password This property is required. string
The user password (string)
Username
This property is required.
Changes to this property will trigger replacement.
string
The user username (string)
Annotations Dictionary<string, string>
Annotations for global role binding (map)
Enabled bool
Labels Dictionary<string, string>
Labels for global role binding (map)
MustChangePassword Changes to this property will trigger replacement. bool
The user must change password at first login (bool)
Name string
The user full name (string)
Password This property is required. string
The user password (string)
Username
This property is required.
Changes to this property will trigger replacement.
string
The user username (string)
Annotations map[string]string
Annotations for global role binding (map)
Enabled bool
Labels map[string]string
Labels for global role binding (map)
MustChangePassword Changes to this property will trigger replacement. bool
The user must change password at first login (bool)
Name string
The user full name (string)
password This property is required. String
The user password (string)
username
This property is required.
Changes to this property will trigger replacement.
String
The user username (string)
annotations Map<String,String>
Annotations for global role binding (map)
enabled Boolean
labels Map<String,String>
Labels for global role binding (map)
mustChangePassword Changes to this property will trigger replacement. Boolean
The user must change password at first login (bool)
name String
The user full name (string)
password This property is required. string
The user password (string)
username
This property is required.
Changes to this property will trigger replacement.
string
The user username (string)
annotations {[key: string]: string}
Annotations for global role binding (map)
enabled boolean
labels {[key: string]: string}
Labels for global role binding (map)
mustChangePassword Changes to this property will trigger replacement. boolean
The user must change password at first login (bool)
name string
The user full name (string)
password This property is required. str
The user password (string)
username
This property is required.
Changes to this property will trigger replacement.
str
The user username (string)
annotations Mapping[str, str]
Annotations for global role binding (map)
enabled bool
labels Mapping[str, str]
Labels for global role binding (map)
must_change_password Changes to this property will trigger replacement. bool
The user must change password at first login (bool)
name str
The user full name (string)
password This property is required. String
The user password (string)
username
This property is required.
Changes to this property will trigger replacement.
String
The user username (string)
annotations Map<String>
Annotations for global role binding (map)
enabled Boolean
labels Map<String>
Labels for global role binding (map)
mustChangePassword Changes to this property will trigger replacement. Boolean
The user must change password at first login (bool)
name String
The user full name (string)

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
PrincipalIds List<string>
(Computed) The user principal IDs (list)
Id string
The provider-assigned unique ID for this managed resource.
PrincipalIds []string
(Computed) The user principal IDs (list)
id String
The provider-assigned unique ID for this managed resource.
principalIds List<String>
(Computed) The user principal IDs (list)
id string
The provider-assigned unique ID for this managed resource.
principalIds string[]
(Computed) The user principal IDs (list)
id str
The provider-assigned unique ID for this managed resource.
principal_ids Sequence[str]
(Computed) The user principal IDs (list)
id String
The provider-assigned unique ID for this managed resource.
principalIds List<String>
(Computed) The user principal IDs (list)

Look up Existing User Resource

Get an existing User 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?: UserState, opts?: CustomResourceOptions): User
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        annotations: Optional[Mapping[str, str]] = None,
        enabled: Optional[bool] = None,
        labels: Optional[Mapping[str, str]] = None,
        must_change_password: Optional[bool] = None,
        name: Optional[str] = None,
        password: Optional[str] = None,
        principal_ids: Optional[Sequence[str]] = None,
        username: Optional[str] = None) -> User
func GetUser(ctx *Context, name string, id IDInput, state *UserState, opts ...ResourceOption) (*User, error)
public static User Get(string name, Input<string> id, UserState? state, CustomResourceOptions? opts = null)
public static User get(String name, Output<String> id, UserState state, CustomResourceOptions options)
resources:  _:    type: rancher2:User    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Annotations Dictionary<string, string>
Annotations for global role binding (map)
Enabled bool
Labels Dictionary<string, string>
Labels for global role binding (map)
MustChangePassword Changes to this property will trigger replacement. bool
The user must change password at first login (bool)
Name string
The user full name (string)
Password string
The user password (string)
PrincipalIds List<string>
(Computed) The user principal IDs (list)
Username Changes to this property will trigger replacement. string
The user username (string)
Annotations map[string]string
Annotations for global role binding (map)
Enabled bool
Labels map[string]string
Labels for global role binding (map)
MustChangePassword Changes to this property will trigger replacement. bool
The user must change password at first login (bool)
Name string
The user full name (string)
Password string
The user password (string)
PrincipalIds []string
(Computed) The user principal IDs (list)
Username Changes to this property will trigger replacement. string
The user username (string)
annotations Map<String,String>
Annotations for global role binding (map)
enabled Boolean
labels Map<String,String>
Labels for global role binding (map)
mustChangePassword Changes to this property will trigger replacement. Boolean
The user must change password at first login (bool)
name String
The user full name (string)
password String
The user password (string)
principalIds List<String>
(Computed) The user principal IDs (list)
username Changes to this property will trigger replacement. String
The user username (string)
annotations {[key: string]: string}
Annotations for global role binding (map)
enabled boolean
labels {[key: string]: string}
Labels for global role binding (map)
mustChangePassword Changes to this property will trigger replacement. boolean
The user must change password at first login (bool)
name string
The user full name (string)
password string
The user password (string)
principalIds string[]
(Computed) The user principal IDs (list)
username Changes to this property will trigger replacement. string
The user username (string)
annotations Mapping[str, str]
Annotations for global role binding (map)
enabled bool
labels Mapping[str, str]
Labels for global role binding (map)
must_change_password Changes to this property will trigger replacement. bool
The user must change password at first login (bool)
name str
The user full name (string)
password str
The user password (string)
principal_ids Sequence[str]
(Computed) The user principal IDs (list)
username Changes to this property will trigger replacement. str
The user username (string)
annotations Map<String>
Annotations for global role binding (map)
enabled Boolean
labels Map<String>
Labels for global role binding (map)
mustChangePassword Changes to this property will trigger replacement. Boolean
The user must change password at first login (bool)
name String
The user full name (string)
password String
The user password (string)
principalIds List<String>
(Computed) The user principal IDs (list)
username Changes to this property will trigger replacement. String
The user username (string)

Import

Users can be imported using the Rancher User ID

$ pulumi import rancher2:index/user:User foo &lt;user_id&gt;
Copy

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

Package Details

Repository
Rancher2 pulumi/pulumi-rancher2
License
Apache-2.0
Notes
This Pulumi package is based on the rancher2 Terraform Provider.