API endpoint for removing a device

147 views Asked by At

I want to know if there is an endpoint that I could use to remove a device by its hostname.

For example, I have a terraform script with Cloudinit which adds a VPS to Tailscale and works perfectly fine. However, I want to destroy the VM simultaneously without going to Tailscale's admin console to remove it.

Is an API for that?

1

There are 1 answers

2
jbielick On BEST ANSWER

The API for deleting a node from the tailnet is documented here: https://github.com/tailscale/tailscale/blob/main/api.md#delete-device


It seems like you are describing the behavior of an ephemeral node, so here is some information about how to leverage that feature in case it is helpful to you or others:

Ephemeral Auth Keys

If the auth key you're using to add the node is configured as Ephemeral, the node will eventually disappear after a period of inactivity or it will disappear immediately if you use tailscale logout.

Ephemeral tailscaled state

(If you're using version >=1.22)

Another option is to use --state=mem: as a flag for tailscaled (note, this is not a tailscale CLI flag, it is a flag for the daemon itself). Using memory state will mark the machine as ephemeral as well.

From the help output:

  -state string
        ...
        use 'mem:' to not store state and register as an ephemeral node. If empty and --statedir is provided, the default is <statedir>/tailscaled.state.