Skip to content

Commit ca94a36

Browse files
committed
On 404 response, reset resource id to force recreation
1 parent 8b2932c commit ca94a36

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tailscale/resource_device_subnet_routes.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ func resourceDeviceSubnetRoutesRead(ctx context.Context, d *schema.ResourceData,
6262
deviceID := d.Get("device_id").(string)
6363

6464
routes, err := client.Devices().SubnetRoutes(ctx, deviceID)
65+
6566
if err != nil {
67+
// If the device is not found, remove from the state so we can create it again.
68+
if tailscale.IsNotFound(err) {
69+
d.SetId("")
70+
return nil
71+
}
72+
6673
return diagnosticsError(err, "Failed to fetch device subnet routes")
6774
}
6875

0 commit comments

Comments
 (0)