1. Packages
  2. Lxd Provider
  3. API Docs
  4. TrustToken
lxd 2.5.0 published on Thursday, Mar 13, 2025 by terraform-lxd

lxd.TrustToken

Explore with Pulumi AI

lxd logo
lxd 2.5.0 published on Thursday, Mar 13, 2025 by terraform-lxd

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as lxd from "@pulumi/lxd";
    
    const token1 = new lxd.TrustToken("token1", {});
    export const token = token1.token;
    
    import pulumi
    import pulumi_lxd as lxd
    
    token1 = lxd.TrustToken("token1")
    pulumi.export("token", token1.token)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/lxd/v2/lxd"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		token1, err := lxd.NewTrustToken(ctx, "token1", nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("token", token1.Token)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Lxd = Pulumi.Lxd;
    
    return await Deployment.RunAsync(() => 
    {
        var token1 = new Lxd.TrustToken("token1");
    
        return new Dictionary<string, object?>
        {
            ["token"] = token1.Token,
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.lxd.TrustToken;
    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 token1 = new TrustToken("token1");
    
            ctx.export("token", token1.token());
        }
    }
    
    resources:
      token1:
        type: lxd:TrustToken
    outputs:
      token: ${token1.token}
    

    Trust token expiry

    Warning: The provider is unable to differentiate between an expired and a consumed token. If token generation is set to once and the token expires, it will not be regenerated.

    Trust token expiry is defined in the server’s configuration (core.remote_token_expiry). If the setting is configured, expires_at attribute will be populated, otherwise, it will be empty.

    For example, to set the token expiry to 20 minutes, run the following command:

    lxc config set core.remote_token_expiry=20M
    

    If trigger is set to once the token will not be regenerated on subsequent plan applies. By setting the trigger to always ensures that the token is always present, and will be regenerated if missing.

    Notes

    • Token’s unique identifier is the operation ID and not the token name. Therefore, multiple tokens can exist with the same name.

    • See the LXD documentation for more information on trust tokens.

    Create TrustToken Resource

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

    Constructor syntax

    new TrustToken(name: string, args?: TrustTokenArgs, opts?: CustomResourceOptions);
    @overload
    def TrustToken(resource_name: str,
                   args: Optional[TrustTokenArgs] = None,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def TrustToken(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   name: Optional[str] = None,
                   projects: Optional[Sequence[str]] = None,
                   remote: Optional[str] = None,
                   trigger: Optional[str] = None)
    func NewTrustToken(ctx *Context, name string, args *TrustTokenArgs, opts ...ResourceOption) (*TrustToken, error)
    public TrustToken(string name, TrustTokenArgs? args = null, CustomResourceOptions? opts = null)
    public TrustToken(String name, TrustTokenArgs args)
    public TrustToken(String name, TrustTokenArgs args, CustomResourceOptions options)
    
    type: lxd:TrustToken
    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 TrustTokenArgs
    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 TrustTokenArgs
    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 TrustTokenArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args TrustTokenArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args TrustTokenArgs
    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 trustTokenResource = new Lxd.TrustToken("trustTokenResource", new()
    {
        Name = "string",
        Projects = new[]
        {
            "string",
        },
        Remote = "string",
        Trigger = "string",
    });
    
    example, err := lxd.NewTrustToken(ctx, "trustTokenResource", &lxd.TrustTokenArgs{
    Name: pulumi.String("string"),
    Projects: pulumi.StringArray{
    pulumi.String("string"),
    },
    Remote: pulumi.String("string"),
    Trigger: pulumi.String("string"),
    })
    
    var trustTokenResource = new TrustToken("trustTokenResource", TrustTokenArgs.builder()
        .name("string")
        .projects("string")
        .remote("string")
        .trigger("string")
        .build());
    
    trust_token_resource = lxd.TrustToken("trustTokenResource",
        name="string",
        projects=["string"],
        remote="string",
        trigger="string")
    
    const trustTokenResource = new lxd.TrustToken("trustTokenResource", {
        name: "string",
        projects: ["string"],
        remote: "string",
        trigger: "string",
    });
    
    type: lxd:TrustToken
    properties:
        name: string
        projects:
            - string
        remote: string
        trigger: string
    

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

    Name string
    Required - Name of the token.
    Projects List<string>
    Optional - List of projects to restrict the token to.
    Remote string
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    Trigger string
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    Name string
    Required - Name of the token.
    Projects []string
    Optional - List of projects to restrict the token to.
    Remote string
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    Trigger string
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    name String
    Required - Name of the token.
    projects List<String>
    Optional - List of projects to restrict the token to.
    remote String
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    trigger String
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    name string
    Required - Name of the token.
    projects string[]
    Optional - List of projects to restrict the token to.
    remote string
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    trigger string
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    name str
    Required - Name of the token.
    projects Sequence[str]
    Optional - List of projects to restrict the token to.
    remote str
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    trigger str
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    name String
    Required - Name of the token.
    projects List<String>
    Optional - List of projects to restrict the token to.
    remote String
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    trigger String
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.

    Outputs

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

    ExpiresAt string
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    Id string
    The provider-assigned unique ID for this managed resource.
    OperationId string
    Token string
    The generated token.
    ExpiresAt string
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    Id string
    The provider-assigned unique ID for this managed resource.
    OperationId string
    Token string
    The generated token.
    expiresAt String
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    id String
    The provider-assigned unique ID for this managed resource.
    operationId String
    token String
    The generated token.
    expiresAt string
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    id string
    The provider-assigned unique ID for this managed resource.
    operationId string
    token string
    The generated token.
    expires_at str
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    id str
    The provider-assigned unique ID for this managed resource.
    operation_id str
    token str
    The generated token.
    expiresAt String
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    id String
    The provider-assigned unique ID for this managed resource.
    operationId String
    token String
    The generated token.

    Look up Existing TrustToken Resource

    Get an existing TrustToken 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?: TrustTokenState, opts?: CustomResourceOptions): TrustToken
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            expires_at: Optional[str] = None,
            name: Optional[str] = None,
            operation_id: Optional[str] = None,
            projects: Optional[Sequence[str]] = None,
            remote: Optional[str] = None,
            token: Optional[str] = None,
            trigger: Optional[str] = None) -> TrustToken
    func GetTrustToken(ctx *Context, name string, id IDInput, state *TrustTokenState, opts ...ResourceOption) (*TrustToken, error)
    public static TrustToken Get(string name, Input<string> id, TrustTokenState? state, CustomResourceOptions? opts = null)
    public static TrustToken get(String name, Output<String> id, TrustTokenState state, CustomResourceOptions options)
    resources:  _:    type: lxd:TrustToken    get:      id: ${id}
    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:
    ExpiresAt string
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    Name string
    Required - Name of the token.
    OperationId string
    Projects List<string>
    Optional - List of projects to restrict the token to.
    Remote string
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    Token string
    The generated token.
    Trigger string
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    ExpiresAt string
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    Name string
    Required - Name of the token.
    OperationId string
    Projects []string
    Optional - List of projects to restrict the token to.
    Remote string
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    Token string
    The generated token.
    Trigger string
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    expiresAt String
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    name String
    Required - Name of the token.
    operationId String
    projects List<String>
    Optional - List of projects to restrict the token to.
    remote String
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    token String
    The generated token.
    trigger String
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    expiresAt string
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    name string
    Required - Name of the token.
    operationId string
    projects string[]
    Optional - List of projects to restrict the token to.
    remote string
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    token string
    The generated token.
    trigger string
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    expires_at str
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    name str
    Required - Name of the token.
    operation_id str
    projects Sequence[str]
    Optional - List of projects to restrict the token to.
    remote str
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    token str
    The generated token.
    trigger str
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.
    expiresAt String
    Time at which the trust token expires. If token expiry is configured, the value will be in format YYYY/MM/DD hh:mm TZ.
    name String
    Required - Name of the token.
    operationId String
    projects List<String>
    Optional - List of projects to restrict the token to.
    remote String
    Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
    token String
    The generated token.
    trigger String
    Optional - When to trigger the token generation. Possible values are once and always (if missing). Defaults to once.

    Package Details

    Repository
    lxd terraform-lxd/terraform-provider-lxd
    License
    Notes
    This Pulumi package is based on the lxd Terraform Provider.
    lxd logo
    lxd 2.5.0 published on Thursday, Mar 13, 2025 by terraform-lxd