1. Packages
  2. Tailscale Provider
  3. API Docs
  4. TailnetKey
Tailscale v0.19.0 published on Thursday, Apr 10, 2025 by Pulumi

tailscale.TailnetKey

Explore with Pulumi AI

The tailnet_key resource allows you to create pre-authentication keys that can register new nodes without needing to sign in via a web browser. See https://tailscale.com/kb/1085/auth-keys for more information

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as tailscale from "@pulumi/tailscale";

const sampleKey = new tailscale.TailnetKey("sample_key", {
    reusable: true,
    ephemeral: false,
    preauthorized: true,
    expiry: 3600,
    description: "Sample key",
});
Copy
import pulumi
import pulumi_tailscale as tailscale

sample_key = tailscale.TailnetKey("sample_key",
    reusable=True,
    ephemeral=False,
    preauthorized=True,
    expiry=3600,
    description="Sample key")
Copy
package main

import (
	"github.com/pulumi/pulumi-tailscale/sdk/go/tailscale"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := tailscale.NewTailnetKey(ctx, "sample_key", &tailscale.TailnetKeyArgs{
			Reusable:      pulumi.Bool(true),
			Ephemeral:     pulumi.Bool(false),
			Preauthorized: pulumi.Bool(true),
			Expiry:        pulumi.Int(3600),
			Description:   pulumi.String("Sample key"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Tailscale = Pulumi.Tailscale;

return await Deployment.RunAsync(() => 
{
    var sampleKey = new Tailscale.TailnetKey("sample_key", new()
    {
        Reusable = true,
        Ephemeral = false,
        Preauthorized = true,
        Expiry = 3600,
        Description = "Sample key",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tailscale.TailnetKey;
import com.pulumi.tailscale.TailnetKeyArgs;
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 sampleKey = new TailnetKey("sampleKey", TailnetKeyArgs.builder()
            .reusable(true)
            .ephemeral(false)
            .preauthorized(true)
            .expiry(3600)
            .description("Sample key")
            .build());

    }
}
Copy
resources:
  sampleKey:
    type: tailscale:TailnetKey
    name: sample_key
    properties:
      reusable: true
      ephemeral: false
      preauthorized: true
      expiry: 3600
      description: Sample key
Copy

Create TailnetKey Resource

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

Constructor syntax

new TailnetKey(name: string, args?: TailnetKeyArgs, opts?: CustomResourceOptions);
@overload
def TailnetKey(resource_name: str,
               args: Optional[TailnetKeyArgs] = None,
               opts: Optional[ResourceOptions] = None)

@overload
def TailnetKey(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               description: Optional[str] = None,
               ephemeral: Optional[bool] = None,
               expiry: Optional[int] = None,
               preauthorized: Optional[bool] = None,
               recreate_if_invalid: Optional[str] = None,
               reusable: Optional[bool] = None,
               tags: Optional[Sequence[str]] = None,
               user_id: Optional[str] = None)
func NewTailnetKey(ctx *Context, name string, args *TailnetKeyArgs, opts ...ResourceOption) (*TailnetKey, error)
public TailnetKey(string name, TailnetKeyArgs? args = null, CustomResourceOptions? opts = null)
public TailnetKey(String name, TailnetKeyArgs args)
public TailnetKey(String name, TailnetKeyArgs args, CustomResourceOptions options)
type: tailscale:TailnetKey
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args TailnetKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args TailnetKeyArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args TailnetKeyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args TailnetKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. TailnetKeyArgs
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 tailnetKeyResource = new Tailscale.TailnetKey("tailnetKeyResource", new()
{
    Description = "string",
    Ephemeral = false,
    Expiry = 0,
    Preauthorized = false,
    RecreateIfInvalid = "string",
    Reusable = false,
    Tags = new[]
    {
        "string",
    },
    UserId = "string",
});
Copy
example, err := tailscale.NewTailnetKey(ctx, "tailnetKeyResource", &tailscale.TailnetKeyArgs{
	Description:       pulumi.String("string"),
	Ephemeral:         pulumi.Bool(false),
	Expiry:            pulumi.Int(0),
	Preauthorized:     pulumi.Bool(false),
	RecreateIfInvalid: pulumi.String("string"),
	Reusable:          pulumi.Bool(false),
	Tags: pulumi.StringArray{
		pulumi.String("string"),
	},
	UserId: pulumi.String("string"),
})
Copy
var tailnetKeyResource = new TailnetKey("tailnetKeyResource", TailnetKeyArgs.builder()
    .description("string")
    .ephemeral(false)
    .expiry(0)
    .preauthorized(false)
    .recreateIfInvalid("string")
    .reusable(false)
    .tags("string")
    .userId("string")
    .build());
Copy
tailnet_key_resource = tailscale.TailnetKey("tailnetKeyResource",
    description="string",
    ephemeral=False,
    expiry=0,
    preauthorized=False,
    recreate_if_invalid="string",
    reusable=False,
    tags=["string"],
    user_id="string")
Copy
const tailnetKeyResource = new tailscale.TailnetKey("tailnetKeyResource", {
    description: "string",
    ephemeral: false,
    expiry: 0,
    preauthorized: false,
    recreateIfInvalid: "string",
    reusable: false,
    tags: ["string"],
    userId: "string",
});
Copy
type: tailscale:TailnetKey
properties:
    description: string
    ephemeral: false
    expiry: 0
    preauthorized: false
    recreateIfInvalid: string
    reusable: false
    tags:
        - string
    userId: string
Copy

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

Description Changes to this property will trigger replacement. string
A description of the key consisting of alphanumeric characters. Defaults to "".
Ephemeral Changes to this property will trigger replacement. bool
Indicates if the key is ephemeral. Defaults to false.
Expiry Changes to this property will trigger replacement. int
The expiry of the key in seconds. Defaults to 7776000 (90 days).
Preauthorized Changes to this property will trigger replacement. bool
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
RecreateIfInvalid string
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
Reusable Changes to this property will trigger replacement. bool
Indicates if the key is reusable or single-use. Defaults to false.
Tags Changes to this property will trigger replacement. List<string>
List of tags to apply to the machines authenticated by the key.
UserId string
ID of the user who created this key, empty for keys created by OAuth clients.
Description Changes to this property will trigger replacement. string
A description of the key consisting of alphanumeric characters. Defaults to "".
Ephemeral Changes to this property will trigger replacement. bool
Indicates if the key is ephemeral. Defaults to false.
Expiry Changes to this property will trigger replacement. int
The expiry of the key in seconds. Defaults to 7776000 (90 days).
Preauthorized Changes to this property will trigger replacement. bool
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
RecreateIfInvalid string
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
Reusable Changes to this property will trigger replacement. bool
Indicates if the key is reusable or single-use. Defaults to false.
Tags Changes to this property will trigger replacement. []string
List of tags to apply to the machines authenticated by the key.
UserId string
ID of the user who created this key, empty for keys created by OAuth clients.
description Changes to this property will trigger replacement. String
A description of the key consisting of alphanumeric characters. Defaults to "".
ephemeral Changes to this property will trigger replacement. Boolean
Indicates if the key is ephemeral. Defaults to false.
expiry Changes to this property will trigger replacement. Integer
The expiry of the key in seconds. Defaults to 7776000 (90 days).
preauthorized Changes to this property will trigger replacement. Boolean
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
recreateIfInvalid String
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
reusable Changes to this property will trigger replacement. Boolean
Indicates if the key is reusable or single-use. Defaults to false.
tags Changes to this property will trigger replacement. List<String>
List of tags to apply to the machines authenticated by the key.
userId String
ID of the user who created this key, empty for keys created by OAuth clients.
description Changes to this property will trigger replacement. string
A description of the key consisting of alphanumeric characters. Defaults to "".
ephemeral Changes to this property will trigger replacement. boolean
Indicates if the key is ephemeral. Defaults to false.
expiry Changes to this property will trigger replacement. number
The expiry of the key in seconds. Defaults to 7776000 (90 days).
preauthorized Changes to this property will trigger replacement. boolean
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
recreateIfInvalid string
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
reusable Changes to this property will trigger replacement. boolean
Indicates if the key is reusable or single-use. Defaults to false.
tags Changes to this property will trigger replacement. string[]
List of tags to apply to the machines authenticated by the key.
userId string
ID of the user who created this key, empty for keys created by OAuth clients.
description Changes to this property will trigger replacement. str
A description of the key consisting of alphanumeric characters. Defaults to "".
ephemeral Changes to this property will trigger replacement. bool
Indicates if the key is ephemeral. Defaults to false.
expiry Changes to this property will trigger replacement. int
The expiry of the key in seconds. Defaults to 7776000 (90 days).
preauthorized Changes to this property will trigger replacement. bool
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
recreate_if_invalid str
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
reusable Changes to this property will trigger replacement. bool
Indicates if the key is reusable or single-use. Defaults to false.
tags Changes to this property will trigger replacement. Sequence[str]
List of tags to apply to the machines authenticated by the key.
user_id str
ID of the user who created this key, empty for keys created by OAuth clients.
description Changes to this property will trigger replacement. String
A description of the key consisting of alphanumeric characters. Defaults to "".
ephemeral Changes to this property will trigger replacement. Boolean
Indicates if the key is ephemeral. Defaults to false.
expiry Changes to this property will trigger replacement. Number
The expiry of the key in seconds. Defaults to 7776000 (90 days).
preauthorized Changes to this property will trigger replacement. Boolean
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
recreateIfInvalid String
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
reusable Changes to this property will trigger replacement. Boolean
Indicates if the key is reusable or single-use. Defaults to false.
tags Changes to this property will trigger replacement. List<String>
List of tags to apply to the machines authenticated by the key.
userId String
ID of the user who created this key, empty for keys created by OAuth clients.

Outputs

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

CreatedAt string
The creation timestamp of the key in RFC3339 format
ExpiresAt string
The expiry timestamp of the key in RFC3339 format
Id string
The provider-assigned unique ID for this managed resource.
Invalid bool
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
Key string
The authentication key
CreatedAt string
The creation timestamp of the key in RFC3339 format
ExpiresAt string
The expiry timestamp of the key in RFC3339 format
Id string
The provider-assigned unique ID for this managed resource.
Invalid bool
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
Key string
The authentication key
createdAt String
The creation timestamp of the key in RFC3339 format
expiresAt String
The expiry timestamp of the key in RFC3339 format
id String
The provider-assigned unique ID for this managed resource.
invalid Boolean
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
key String
The authentication key
createdAt string
The creation timestamp of the key in RFC3339 format
expiresAt string
The expiry timestamp of the key in RFC3339 format
id string
The provider-assigned unique ID for this managed resource.
invalid boolean
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
key string
The authentication key
created_at str
The creation timestamp of the key in RFC3339 format
expires_at str
The expiry timestamp of the key in RFC3339 format
id str
The provider-assigned unique ID for this managed resource.
invalid bool
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
key str
The authentication key
createdAt String
The creation timestamp of the key in RFC3339 format
expiresAt String
The expiry timestamp of the key in RFC3339 format
id String
The provider-assigned unique ID for this managed resource.
invalid Boolean
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
key String
The authentication key

Look up Existing TailnetKey Resource

Get an existing TailnetKey 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?: TailnetKeyState, opts?: CustomResourceOptions): TailnetKey
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        created_at: Optional[str] = None,
        description: Optional[str] = None,
        ephemeral: Optional[bool] = None,
        expires_at: Optional[str] = None,
        expiry: Optional[int] = None,
        invalid: Optional[bool] = None,
        key: Optional[str] = None,
        preauthorized: Optional[bool] = None,
        recreate_if_invalid: Optional[str] = None,
        reusable: Optional[bool] = None,
        tags: Optional[Sequence[str]] = None,
        user_id: Optional[str] = None) -> TailnetKey
func GetTailnetKey(ctx *Context, name string, id IDInput, state *TailnetKeyState, opts ...ResourceOption) (*TailnetKey, error)
public static TailnetKey Get(string name, Input<string> id, TailnetKeyState? state, CustomResourceOptions? opts = null)
public static TailnetKey get(String name, Output<String> id, TailnetKeyState state, CustomResourceOptions options)
resources:  _:    type: tailscale:TailnetKey    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
CreatedAt string
The creation timestamp of the key in RFC3339 format
Description Changes to this property will trigger replacement. string
A description of the key consisting of alphanumeric characters. Defaults to "".
Ephemeral Changes to this property will trigger replacement. bool
Indicates if the key is ephemeral. Defaults to false.
ExpiresAt string
The expiry timestamp of the key in RFC3339 format
Expiry Changes to this property will trigger replacement. int
The expiry of the key in seconds. Defaults to 7776000 (90 days).
Invalid bool
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
Key string
The authentication key
Preauthorized Changes to this property will trigger replacement. bool
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
RecreateIfInvalid string
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
Reusable Changes to this property will trigger replacement. bool
Indicates if the key is reusable or single-use. Defaults to false.
Tags Changes to this property will trigger replacement. List<string>
List of tags to apply to the machines authenticated by the key.
UserId string
ID of the user who created this key, empty for keys created by OAuth clients.
CreatedAt string
The creation timestamp of the key in RFC3339 format
Description Changes to this property will trigger replacement. string
A description of the key consisting of alphanumeric characters. Defaults to "".
Ephemeral Changes to this property will trigger replacement. bool
Indicates if the key is ephemeral. Defaults to false.
ExpiresAt string
The expiry timestamp of the key in RFC3339 format
Expiry Changes to this property will trigger replacement. int
The expiry of the key in seconds. Defaults to 7776000 (90 days).
Invalid bool
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
Key string
The authentication key
Preauthorized Changes to this property will trigger replacement. bool
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
RecreateIfInvalid string
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
Reusable Changes to this property will trigger replacement. bool
Indicates if the key is reusable or single-use. Defaults to false.
Tags Changes to this property will trigger replacement. []string
List of tags to apply to the machines authenticated by the key.
UserId string
ID of the user who created this key, empty for keys created by OAuth clients.
createdAt String
The creation timestamp of the key in RFC3339 format
description Changes to this property will trigger replacement. String
A description of the key consisting of alphanumeric characters. Defaults to "".
ephemeral Changes to this property will trigger replacement. Boolean
Indicates if the key is ephemeral. Defaults to false.
expiresAt String
The expiry timestamp of the key in RFC3339 format
expiry Changes to this property will trigger replacement. Integer
The expiry of the key in seconds. Defaults to 7776000 (90 days).
invalid Boolean
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
key String
The authentication key
preauthorized Changes to this property will trigger replacement. Boolean
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
recreateIfInvalid String
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
reusable Changes to this property will trigger replacement. Boolean
Indicates if the key is reusable or single-use. Defaults to false.
tags Changes to this property will trigger replacement. List<String>
List of tags to apply to the machines authenticated by the key.
userId String
ID of the user who created this key, empty for keys created by OAuth clients.
createdAt string
The creation timestamp of the key in RFC3339 format
description Changes to this property will trigger replacement. string
A description of the key consisting of alphanumeric characters. Defaults to "".
ephemeral Changes to this property will trigger replacement. boolean
Indicates if the key is ephemeral. Defaults to false.
expiresAt string
The expiry timestamp of the key in RFC3339 format
expiry Changes to this property will trigger replacement. number
The expiry of the key in seconds. Defaults to 7776000 (90 days).
invalid boolean
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
key string
The authentication key
preauthorized Changes to this property will trigger replacement. boolean
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
recreateIfInvalid string
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
reusable Changes to this property will trigger replacement. boolean
Indicates if the key is reusable or single-use. Defaults to false.
tags Changes to this property will trigger replacement. string[]
List of tags to apply to the machines authenticated by the key.
userId string
ID of the user who created this key, empty for keys created by OAuth clients.
created_at str
The creation timestamp of the key in RFC3339 format
description Changes to this property will trigger replacement. str
A description of the key consisting of alphanumeric characters. Defaults to "".
ephemeral Changes to this property will trigger replacement. bool
Indicates if the key is ephemeral. Defaults to false.
expires_at str
The expiry timestamp of the key in RFC3339 format
expiry Changes to this property will trigger replacement. int
The expiry of the key in seconds. Defaults to 7776000 (90 days).
invalid bool
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
key str
The authentication key
preauthorized Changes to this property will trigger replacement. bool
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
recreate_if_invalid str
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
reusable Changes to this property will trigger replacement. bool
Indicates if the key is reusable or single-use. Defaults to false.
tags Changes to this property will trigger replacement. Sequence[str]
List of tags to apply to the machines authenticated by the key.
user_id str
ID of the user who created this key, empty for keys created by OAuth clients.
createdAt String
The creation timestamp of the key in RFC3339 format
description Changes to this property will trigger replacement. String
A description of the key consisting of alphanumeric characters. Defaults to "".
ephemeral Changes to this property will trigger replacement. Boolean
Indicates if the key is ephemeral. Defaults to false.
expiresAt String
The expiry timestamp of the key in RFC3339 format
expiry Changes to this property will trigger replacement. Number
The expiry of the key in seconds. Defaults to 7776000 (90 days).
invalid Boolean
Indicates whether the key is invalid (e.g. expired, revoked or has been deleted).
key String
The authentication key
preauthorized Changes to this property will trigger replacement. Boolean
Determines whether or not the machines authenticated by the key will be authorized for the tailnet by default. Defaults to false.
recreateIfInvalid String
Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
reusable Changes to this property will trigger replacement. Boolean
Indicates if the key is reusable or single-use. Defaults to false.
tags Changes to this property will trigger replacement. List<String>
List of tags to apply to the machines authenticated by the key.
userId String
ID of the user who created this key, empty for keys created by OAuth clients.

Import

Tailnet key can be imported using the key id, e.g.,

$ pulumi import tailscale:index/tailnetKey:TailnetKey sample_key 123456789
Copy

-> ** Note ** the key attribute will not be populated on import as this attribute is only populated

on resource creation.

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

Package Details

Repository
tailscale pulumi/pulumi-tailscale
License
Apache-2.0
Notes
This Pulumi package is based on the tailscale Terraform Provider.