Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

User

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

using Pulumi;
using Rancher2 = Pulumi.Rancher2;

class MyStack : Stack
{
    public MyStack()
    {
        // Create a new rancher2 User
        var fooUser = new Rancher2.User("fooUser", new Rancher2.UserArgs
        {
            Username = "foo",
            Password = "changeme",
            Enabled = true,
        });
        // Create a new rancher2 global_role_binding for User
        var fooGlobalRoleBinding = new Rancher2.GlobalRoleBinding("fooGlobalRoleBinding", new Rancher2.GlobalRoleBindingArgs
        {
            GlobalRoleId = "user-base",
            UserId = fooUser.Id,
        });
    }

}
package main

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

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        fooUser, err := rancher2.NewUser(ctx, "fooUser", &rancher2.UserArgs{
            Username: pulumi.String("foo"),
            Password: pulumi.String("changeme"),
            Enabled:  pulumi.Bool(true),
        })
        if err != nil {
            return err
        }
        _, err = rancher2.NewGlobalRoleBinding(ctx, "fooGlobalRoleBinding", &rancher2.GlobalRoleBindingArgs{
            GlobalRoleId: pulumi.String("user-base"),
            UserId:       fooUser.ID(),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_rancher2 as rancher2

# Create a new rancher2 User
foo_user = rancher2.User("fooUser",
    username="foo",
    password="changeme",
    enabled=True)
# Create a new rancher2 global_role_binding for User
foo_global_role_binding = rancher2.GlobalRoleBinding("fooGlobalRoleBinding",
    global_role_id="user-base",
    user_id=foo_user.id)
import * as pulumi from "@pulumi/pulumi";
import * as rancher2 from "@pulumi/rancher2";

// Create a new rancher2 User
const fooUser = new rancher2.User("fooUser", {
    username: "foo",
    password: "changeme",
    enabled: true,
});
// Create a new rancher2 global_role_binding for User
const fooGlobalRoleBinding = new rancher2.GlobalRoleBinding("fooGlobalRoleBinding", {
    globalRoleId: "user-base",
    userId: fooUser.id,
});

Create a User Resource

new User(name: string, args: UserArgs, opts?: CustomResourceOptions);
def User(resource_name: str, opts: Optional[ResourceOptions] = None, annotations: Optional[Mapping[str, Any]] = None, enabled: Optional[bool] = None, labels: Optional[Mapping[str, Any]] = None, name: Optional[str] = None, password: Optional[str] = None, username: Optional[str] = None)
func NewUser(ctx *Context, name string, args UserArgs, opts ...ResourceOption) (*User, error)
public User(string name, UserArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args UserArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

User Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The User resource accepts the following input properties:

Password string

The user password (string)

Username string

The user username (string)

Annotations Dictionary<string, object>

Annotations for global role binding (map)

Enabled bool
Labels Dictionary<string, object>

Labels for global role binding (map)

Name string

The user full name (string)

Password string

The user password (string)

Username string

The user username (string)

Annotations map[string]interface{}

Annotations for global role binding (map)

Enabled bool
Labels map[string]interface{}

Labels for global role binding (map)

Name string

The user full name (string)

password string

The user password (string)

username string

The user username (string)

annotations {[key: string]: any}

Annotations for global role binding (map)

enabled boolean
labels {[key: string]: any}

Labels for global role binding (map)

name string

The user full name (string)

password str

The user password (string)

username str

The user username (string)

annotations Mapping[str, Any]

Annotations for global role binding (map)

enabled bool
labels Mapping[str, Any]

Labels for global role binding (map)

name str

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 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)

Look up an 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, Any]] = None, enabled: Optional[bool] = None, labels: Optional[Mapping[str, Any]] = 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)
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.

The following state arguments are supported:

Annotations Dictionary<string, object>

Annotations for global role binding (map)

Enabled bool
Labels Dictionary<string, object>

Labels for global role binding (map)

Name string

The user full name (string)

Password string

The user password (string)

PrincipalIds List<string>

(Computed) The user principal IDs (list)

Username string

The user username (string)

Annotations map[string]interface{}

Annotations for global role binding (map)

Enabled bool
Labels map[string]interface{}

Labels for global role binding (map)

Name string

The user full name (string)

Password string

The user password (string)

PrincipalIds []string

(Computed) The user principal IDs (list)

Username string

The user username (string)

annotations {[key: string]: any}

Annotations for global role binding (map)

enabled boolean
labels {[key: string]: any}

Labels for global role binding (map)

name string

The user full name (string)

password string

The user password (string)

principalIds string[]

(Computed) The user principal IDs (list)

username string

The user username (string)

annotations Mapping[str, Any]

Annotations for global role binding (map)

enabled bool
labels Mapping[str, Any]

Labels for global role binding (map)

name str

The user full name (string)

password str

The user password (string)

principal_ids Sequence[str]

(Computed) The user principal IDs (list)

username str

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;

Package Details

Repository
https://github.com/pulumi/pulumi-rancher2
License
Apache-2.0
Notes
This Pulumi package is based on the rancher2 Terraform Provider.