Skip to content

Commit 07ded36

Browse files
committed
tailscale_device_authorization: hande missing device on state refresh
Remove authorization resource for a devices if device request returns 404. Fixes #585 Signed-off-by: Dmitry Pyzhov <[email protected]>
1 parent 530e5f6 commit 07ded36

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tailscale/resource_device_authorization.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ func resourceDeviceAuthorizationRead(ctx context.Context, d *schema.ResourceData
4242
deviceID := d.Id()
4343

4444
device, err := client.Devices().Get(ctx, deviceID)
45-
if err != nil {
45+
switch {
46+
case tailscale.IsNotFound(err):
47+
d.SetId("")
48+
return nil
49+
case err != nil:
4650
return diagnosticsError(err, "Failed to fetch device")
4751
}
4852

0 commit comments

Comments
 (0)