1. Packages
  2. Proxmox Virtual Environment (Proxmox VE)
  3. API Docs
  4. User
  5. Token
Proxmox Virtual Environment (Proxmox VE) v6.15.3 published on Monday, Nov 11, 2024 by Daniel Muehlbachler-Pietrzykowski

proxmoxve.User.Token

Explore with Pulumi AI

proxmoxve logo
Proxmox Virtual Environment (Proxmox VE) v6.15.3 published on Monday, Nov 11, 2024 by Daniel Muehlbachler-Pietrzykowski

    User API tokens.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as proxmoxve from "@muhlba91/pulumi-proxmoxve";
    
    // if creating a user token, the user must be created first
    const user = new proxmoxve.permission.User("user", {
        comment: "Managed by Terraform",
        email: "user@pve",
        enabled: true,
        expirationDate: "2034-01-01T22:00:00Z",
        userId: "user@pve",
    });
    const userToken = new proxmoxve.user.Token("userToken", {
        comment: "Managed by Terraform",
        expirationDate: "2033-01-01T22:00:00Z",
        tokenName: "tk1",
        userId: user.userId,
    });
    
    import pulumi
    import pulumi_proxmoxve as proxmoxve
    
    # if creating a user token, the user must be created first
    user = proxmoxve.permission.User("user",
        comment="Managed by Terraform",
        email="user@pve",
        enabled=True,
        expiration_date="2034-01-01T22:00:00Z",
        user_id="user@pve")
    user_token = proxmoxve.user.Token("userToken",
        comment="Managed by Terraform",
        expiration_date="2033-01-01T22:00:00Z",
        token_name="tk1",
        user_id=user.user_id)
    
    package main
    
    import (
    	"github.com/muhlba91/pulumi-proxmoxve/sdk/v6/go/proxmoxve/Permission"
    	"github.com/muhlba91/pulumi-proxmoxve/sdk/v6/go/proxmoxve/User"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// if creating a user token, the user must be created first
    		user, err := Permission.NewUser(ctx, "user", &Permission.UserArgs{
    			Comment:        pulumi.String("Managed by Terraform"),
    			Email:          pulumi.String("user@pve"),
    			Enabled:        pulumi.Bool(true),
    			ExpirationDate: pulumi.String("2034-01-01T22:00:00Z"),
    			UserId:         pulumi.String("user@pve"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = User.NewToken(ctx, "userToken", &User.TokenArgs{
    			Comment:        pulumi.String("Managed by Terraform"),
    			ExpirationDate: pulumi.String("2033-01-01T22:00:00Z"),
    			TokenName:      pulumi.String("tk1"),
    			UserId:         user.UserId,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using ProxmoxVE = Pulumi.ProxmoxVE;
    
    return await Deployment.RunAsync(() => 
    {
        // if creating a user token, the user must be created first
        var user = new ProxmoxVE.Permission.User("user", new()
        {
            Comment = "Managed by Terraform",
            Email = "user@pve",
            Enabled = true,
            ExpirationDate = "2034-01-01T22:00:00Z",
            UserId = "user@pve",
        });
    
        var userToken = new ProxmoxVE.User.Token("userToken", new()
        {
            Comment = "Managed by Terraform",
            ExpirationDate = "2033-01-01T22:00:00Z",
            TokenName = "tk1",
            UserId = user.UserId,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.proxmoxve.Permission.User;
    import com.pulumi.proxmoxve.Permission.UserArgs;
    import com.pulumi.proxmoxve.User.Token;
    import com.pulumi.proxmoxve.User.TokenArgs;
    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) {
            // if creating a user token, the user must be created first
            var user = new User("user", UserArgs.builder()
                .comment("Managed by Terraform")
                .email("user@pve")
                .enabled(true)
                .expirationDate("2034-01-01T22:00:00Z")
                .userId("user@pve")
                .build());
    
            var userToken = new Token("userToken", TokenArgs.builder()
                .comment("Managed by Terraform")
                .expirationDate("2033-01-01T22:00:00Z")
                .tokenName("tk1")
                .userId(user.userId())
                .build());
    
        }
    }
    
    resources:
      # if creating a user token, the user must be created first
      user:
        type: proxmoxve:Permission:User
        properties:
          comment: Managed by Terraform
          email: user@pve
          enabled: true
          expirationDate: 2034-01-01T22:00:00Z
          userId: user@pve
      userToken:
        type: proxmoxve:User:Token
        properties:
          comment: Managed by Terraform
          expirationDate: 2033-01-01T22:00:00Z
          tokenName: tk1
          userId: ${user.userId}
    

    Create Token Resource

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

    Constructor syntax

    new Token(name: string, args: TokenArgs, opts?: CustomResourceOptions);
    @overload
    def Token(resource_name: str,
              args: TokenArgs,
              opts: Optional[ResourceOptions] = None)
    
    @overload
    def Token(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              token_name: Optional[str] = None,
              user_id: Optional[str] = None,
              comment: Optional[str] = None,
              expiration_date: Optional[str] = None,
              privileges_separation: Optional[bool] = None)
    func NewToken(ctx *Context, name string, args TokenArgs, opts ...ResourceOption) (*Token, error)
    public Token(string name, TokenArgs args, CustomResourceOptions? opts = null)
    public Token(String name, TokenArgs args)
    public Token(String name, TokenArgs args, CustomResourceOptions options)
    
    type: proxmoxve:User:Token
    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 TokenArgs
    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 TokenArgs
    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 TokenArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args TokenArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args TokenArgs
    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 tokenResource = new ProxmoxVE.User.Token("tokenResource", new()
    {
        TokenName = "string",
        UserId = "string",
        Comment = "string",
        ExpirationDate = "string",
        PrivilegesSeparation = false,
    });
    
    example, err := User.NewToken(ctx, "tokenResource", &User.TokenArgs{
    	TokenName:            pulumi.String("string"),
    	UserId:               pulumi.String("string"),
    	Comment:              pulumi.String("string"),
    	ExpirationDate:       pulumi.String("string"),
    	PrivilegesSeparation: pulumi.Bool(false),
    })
    
    var tokenResource = new Token("tokenResource", TokenArgs.builder()
        .tokenName("string")
        .userId("string")
        .comment("string")
        .expirationDate("string")
        .privilegesSeparation(false)
        .build());
    
    token_resource = proxmoxve.user.Token("tokenResource",
        token_name="string",
        user_id="string",
        comment="string",
        expiration_date="string",
        privileges_separation=False)
    
    const tokenResource = new proxmoxve.user.Token("tokenResource", {
        tokenName: "string",
        userId: "string",
        comment: "string",
        expirationDate: "string",
        privilegesSeparation: false,
    });
    
    type: proxmoxve:User:Token
    properties:
        comment: string
        expirationDate: string
        privilegesSeparation: false
        tokenName: string
        userId: string
    

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

    TokenName string
    User-specific token identifier.
    UserId string
    User identifier.
    Comment string
    Comment for the token.
    ExpirationDate string
    Expiration date for the token.
    PrivilegesSeparation bool
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    TokenName string
    User-specific token identifier.
    UserId string
    User identifier.
    Comment string
    Comment for the token.
    ExpirationDate string
    Expiration date for the token.
    PrivilegesSeparation bool
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    tokenName String
    User-specific token identifier.
    userId String
    User identifier.
    comment String
    Comment for the token.
    expirationDate String
    Expiration date for the token.
    privilegesSeparation Boolean
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    tokenName string
    User-specific token identifier.
    userId string
    User identifier.
    comment string
    Comment for the token.
    expirationDate string
    Expiration date for the token.
    privilegesSeparation boolean
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    token_name str
    User-specific token identifier.
    user_id str
    User identifier.
    comment str
    Comment for the token.
    expiration_date str
    Expiration date for the token.
    privileges_separation bool
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    tokenName String
    User-specific token identifier.
    userId String
    User identifier.
    comment String
    Comment for the token.
    expirationDate String
    Expiration date for the token.
    privilegesSeparation Boolean
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Value string
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    Id string
    The provider-assigned unique ID for this managed resource.
    Value string
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    id String
    The provider-assigned unique ID for this managed resource.
    value String
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    id string
    The provider-assigned unique ID for this managed resource.
    value string
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    id str
    The provider-assigned unique ID for this managed resource.
    value str
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    id String
    The provider-assigned unique ID for this managed resource.
    value String
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.

    Look up Existing Token Resource

    Get an existing Token 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?: TokenState, opts?: CustomResourceOptions): Token
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            comment: Optional[str] = None,
            expiration_date: Optional[str] = None,
            privileges_separation: Optional[bool] = None,
            token_name: Optional[str] = None,
            user_id: Optional[str] = None,
            value: Optional[str] = None) -> Token
    func GetToken(ctx *Context, name string, id IDInput, state *TokenState, opts ...ResourceOption) (*Token, error)
    public static Token Get(string name, Input<string> id, TokenState? state, CustomResourceOptions? opts = null)
    public static Token get(String name, Output<String> id, TokenState 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:
    Comment string
    Comment for the token.
    ExpirationDate string
    Expiration date for the token.
    PrivilegesSeparation bool
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    TokenName string
    User-specific token identifier.
    UserId string
    User identifier.
    Value string
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    Comment string
    Comment for the token.
    ExpirationDate string
    Expiration date for the token.
    PrivilegesSeparation bool
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    TokenName string
    User-specific token identifier.
    UserId string
    User identifier.
    Value string
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    comment String
    Comment for the token.
    expirationDate String
    Expiration date for the token.
    privilegesSeparation Boolean
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    tokenName String
    User-specific token identifier.
    userId String
    User identifier.
    value String
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    comment string
    Comment for the token.
    expirationDate string
    Expiration date for the token.
    privilegesSeparation boolean
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    tokenName string
    User-specific token identifier.
    userId string
    User identifier.
    value string
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    comment str
    Comment for the token.
    expiration_date str
    Expiration date for the token.
    privileges_separation bool
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    token_name str
    User-specific token identifier.
    user_id str
    User identifier.
    value str
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.
    comment String
    Comment for the token.
    expirationDate String
    Expiration date for the token.
    privilegesSeparation Boolean
    Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user.
    tokenName String
    User-specific token identifier.
    userId String
    User identifier.
    value String
    API token value used for authentication. It is populated only when creating a new token, and can't be retrieved at import.

    Import

    #!/usr/bin/env sh

    #Tokens can be imported using they identifiers in format user_id!token_name format, e.g.:

    $ pulumi import proxmoxve:User/token:Token token1 user@pve!token1
    

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

    Package Details

    Repository
    proxmoxve muhlba91/pulumi-proxmoxve
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the proxmox Terraform Provider.
    proxmoxve logo
    Proxmox Virtual Environment (Proxmox VE) v6.15.3 published on Monday, Nov 11, 2024 by Daniel Muehlbachler-Pietrzykowski