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,
});
// Create a new rancher2 global_role_binding for User
const fooGlobalRoleBinding = new rancher2.GlobalRoleBinding("foo", {
name: "foo",
globalRoleId: "user-base",
userId: foo.id,
});
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)
# 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)
package main
import (
"github.com/pulumi/pulumi-rancher2/sdk/v7/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),
})
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
})
}
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,
});
// Create a new rancher2 global_role_binding for User
var fooGlobalRoleBinding = new Rancher2.GlobalRoleBinding("foo", new()
{
Name = "foo",
GlobalRoleId = "user-base",
UserId = foo.Id,
});
});
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)
.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());
}
}
resources:
# Create a new rancher2 User
foo:
type: rancher2:User
properties:
name: Foo user
username: foo
password: changeme
enabled: 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}
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,
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)
type: rancher2:User
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 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.
- args 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 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.
- name String
- The unique name of the resource.
- args 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" },
},
Name = "string",
});
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"),
},
Name: pulumi.String("string"),
})
var userResource = new User("userResource", UserArgs.builder()
.password("string")
.username("string")
.annotations(Map.of("string", "string"))
.enabled(false)
.labels(Map.of("string", "string"))
.name("string")
.build());
user_resource = rancher2.User("userResource",
password="string",
username="string",
annotations={
"string": "string",
},
enabled=False,
labels={
"string": "string",
},
name="string")
const userResource = new rancher2.User("userResource", {
password: "string",
username: "string",
annotations: {
string: "string",
},
enabled: false,
labels: {
string: "string",
},
name: "string",
});
type: rancher2:User
properties:
annotations:
string: string
enabled: false
labels:
string: string
name: string
password: string
username: string
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:
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.
- Principal
Ids List<string> - (Computed) The user principal IDs (list)
- Id string
- The provider-assigned unique ID for this managed resource.
- Principal
Ids []string - (Computed) The user principal IDs (list)
- id String
- The provider-assigned unique ID for this managed resource.
- principal
Ids List<String> - (Computed) The user principal IDs (list)
- id string
- The provider-assigned unique ID for this managed resource.
- principal
Ids 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.
- principal
Ids 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,
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)
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.
- Annotations Dictionary<string, string>
- Annotations for global role binding (map)
- Enabled bool
- Labels Dictionary<string, string>
- Labels for global role binding (map)
- Name string
- The user full name (string)
- Password string
- The user password (string)
- Principal
Ids List<string> - (Computed) The user principal IDs (list)
- Username 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)
- Name string
- The user full name (string)
- Password string
- The user password (string)
- Principal
Ids []string - (Computed) The user principal IDs (list)
- Username 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)
- name String
- The user full name (string)
- password String
- The user password (string)
- principal
Ids List<String> - (Computed) The user principal IDs (list)
- username 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)
- name string
- The user full name (string)
- password string
- The user password (string)
- principal
Ids string[] - (Computed) The user principal IDs (list)
- username 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)
- 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)
- annotations Map<String>
- Annotations for global role binding (map)
- enabled Boolean
- labels Map<String>
- Labels for global role binding (map)
- name String
- The user full name (string)
- password String
- The user password (string)
- principal
Ids List<String> - (Computed) The user principal IDs (list)
- username String
- The user username (string)
Import
Users can be imported using the Rancher User ID
$ pulumi import rancher2:index/user:User foo <user_id>
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.