Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tailscale/resource_device_subnet_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func resourceDeviceSubnetRoutes() *schema.Resource {
Type: schema.TypeString,
Required: true,
Description: "The device to set subnet routes for",
ForceNew: true,
},
"routes": {
Type: schema.TypeSet,
Expand All @@ -62,7 +63,14 @@ func resourceDeviceSubnetRoutesRead(ctx context.Context, d *schema.ResourceData,
deviceID := d.Get("device_id").(string)

routes, err := client.Devices().SubnetRoutes(ctx, deviceID)

if err != nil {
// If the device is not found, remove from the state so we can create it again.
if tailscale.IsNotFound(err) {
d.SetId("")
return nil
}

return diagnosticsError(err, "Failed to fetch device subnet routes")
}

Expand Down