1. Packages
  2. Rancher2
  3. API Docs
  4. User
Rancher 2 v6.1.0 published on Tuesday, Mar 12, 2024 by Pulumi

rancher2.User

Explore with Pulumi AI

rancher2 logo
Rancher 2 v6.1.0 published on Tuesday, Mar 12, 2024 by Pulumi

    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 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,
    });
    
    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)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-rancher2/sdk/v6/go/rancher2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Create a new rancher2 User
    		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
    		}
    		// Create a new rancher2 global_role_binding for User
    		_, err = rancher2.NewGlobalRoleBinding(ctx, "fooGlobalRoleBinding", &rancher2.GlobalRoleBindingArgs{
    			GlobalRoleId: pulumi.String("user-base"),
    			UserId:       fooUser.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 fooUser = new Rancher2.User("fooUser", new()
        {
            Username = "foo",
            Password = "changeme",
            Enabled = true,
        });
    
        // Create a new rancher2 global_role_binding for User
        var fooGlobalRoleBinding = new Rancher2.GlobalRoleBinding("fooGlobalRoleBinding", new()
        {
            GlobalRoleId = "user-base",
            UserId = fooUser.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) {
            var fooUser = new User("fooUser", UserArgs.builder()        
                .username("foo")
                .password("changeme")
                .enabled(true)
                .build());
    
            var fooGlobalRoleBinding = new GlobalRoleBinding("fooGlobalRoleBinding", GlobalRoleBindingArgs.builder()        
                .globalRoleId("user-base")
                .userId(fooUser.id())
                .build());
    
        }
    }
    
    resources:
      # Create a new rancher2 User
      fooUser:
        type: rancher2:User
        properties:
          username: foo
          password: changeme
          enabled: true
      # Create a new rancher2 global_role_binding for User
      fooGlobalRoleBinding:
        type: rancher2:GlobalRoleBinding
        properties:
          globalRoleId: user-base
          userId: ${fooUser.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, Any]] = None,
             enabled: Optional[bool] = None,
             labels: Optional[Mapping[str, Any]] = 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 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.

    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", "any" },
        },
        Enabled = false,
        Labels = 
        {
            { "string", "any" },
        },
        Name = "string",
    });
    
    example, err := rancher2.NewUser(ctx, "userResource", &rancher2.UserArgs{
    	Password: pulumi.String("string"),
    	Username: pulumi.String("string"),
    	Annotations: pulumi.Map{
    		"string": pulumi.Any("any"),
    	},
    	Enabled: pulumi.Bool(false),
    	Labels: pulumi.Map{
    		"string": pulumi.Any("any"),
    	},
    	Name: pulumi.String("string"),
    })
    
    var userResource = new User("userResource", UserArgs.builder()        
        .password("string")
        .username("string")
        .annotations(Map.of("string", "any"))
        .enabled(false)
        .labels(Map.of("string", "any"))
        .name("string")
        .build());
    
    user_resource = rancher2.User("userResource",
        password="string",
        username="string",
        annotations={
            "string": "any",
        },
        enabled=False,
        labels={
            "string": "any",
        },
        name="string")
    
    const userResource = new rancher2.User("userResource", {
        password: "string",
        username: "string",
        annotations: {
            string: "any",
        },
        enabled: false,
        labels: {
            string: "any",
        },
        name: "string",
    });
    
    type: rancher2:User
    properties:
        annotations:
            string: any
        enabled: false
        labels:
            string: any
        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

    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 Map<String,Object>
    Annotations for global role binding (map)
    enabled Boolean
    labels Map<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 {[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)
    password String
    The user password (string)
    username String
    The user username (string)
    annotations Map<Any>
    Annotations for global role binding (map)
    enabled Boolean
    labels Map<Any>
    Labels for global role binding (map)
    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, 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)
    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.
    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 Map<String,Object>
    Annotations for global role binding (map)
    enabled Boolean
    labels Map<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 {[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)
    annotations Map<Any>
    Annotations for global role binding (map)
    enabled Boolean
    labels Map<Any>
    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)

    Import

    Users can be imported using the Rancher User ID

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

    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.
    rancher2 logo
    Rancher 2 v6.1.0 published on Tuesday, Mar 12, 2024 by Pulumi