terraform-provider-tailscale icon indicating copy to clipboard operation
terraform-provider-tailscale copied to clipboard

resource_device_authorization: update delete

Open defo89 opened this issue 2 years ago • 2 comments

deletes the device on authorization resouce deletion

What this PR does / why we need it: Ability to delete device with provider

Which issue this PR fixes: fixes #68

defo89 avatar Oct 10 '22 15:10 defo89

Worth to mention: if multiple resources are created/destroyed in a single run, users may face an error that some resources failed to be destroyed (due to device being removed already).

data "tailscale_device" "device1" {
  name     = "device1"
  wait_for = "60s"
}

resource "tailscale_device_authorization" "authorization" {
  device_id  = data.tailscale_device.device1.id
  authorized = true
}

resource "tailscale_device_key" "key" {
  device_id           = data.tailscale_device.device1.id
  key_expiry_disabled = true
}

resource "tailscale_device_subnet_routes" "routes" {
  device_id = data.tailscale_device.device1.id
  routes = local.routes
}
› terraform destroy -auto-approve
---snip---
Error: Failed to set device subnet routes
internal server error (500)

Error: failed to update device key
internal server error (500)

User will have to make sure that device deletion happens last.

defo89 avatar Oct 10 '22 15:10 defo89

if multiple resources are created/destroyed in a single run, users may face an error that some resources failed to be destroyed (due to device being removed already).

This is part of the reason I don't like us managing deletion without creation, the UX suffers in a non-obvious way.

davidsbond avatar Oct 10 '22 16:10 davidsbond