Skip to content

tailscale_device_subnet_routes resource fails to update when previous device_id no longer exists #526

@bdalpe

Description

@bdalpe

Describe the bug
tailscale_device_subnet_routes resource cannot be updated after being previously applied to a now deleted ephemeral device.

To Reproduce
Steps to reproduce the behaviour:

  • Apply Terraform code.
resource "tailscale_tailnet_key" "this" {
  reusable    = true
  expiry = 90 * 24 * 60 * 60 # 90 days
  ephemeral   = true
  description = "Kubernetes Cluster"
  tags = ["tag:k8s"]
}

# ... k8s pod definition ...

data "tailscale_devices" "ts_devices" {
  name_prefix = "tailscale-subnet-router-"

  depends_on = [kubernetes_deployment_v1.this]
}

resource "tailscale_device_subnet_routes" "routes" {
  device_id = data.tailscale_devices.ts_devices.devices[0].node_id
  routes = [
    "10.42.0.0/16",
    "10.43.0.0/16",
    "192.168.1.0/24",
    # Configure as an exit node
    "0.0.0.0/0",
    "::/0"
  ]
}
...
  • Delete the Pod in the Kubernetes cluster. A new pod is created with a new hostname.

  • Attempt to apply the Terraform again.

  • Received the following error:

Error: Failed to fetch device subnet routes
no manageable device matching this ID found (404)

Expected behaviour
tailscale_device_subnet_routes resource should be marked for replacement when device_id field changes.

Additionally, fail gracefully if the device doesn't exist in Tailscale anymore.

Desktop (please complete the following information):

  • OS: Mac OS X 15.5
  • OpenTofu Version 1.9.0
  • Provider Version 0.21.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions