Skip to content

Handle Missing Devices and Enforce Recreation on device_id Change for tailscale_device_subnet_routes #527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bdalpe
Copy link

@bdalpe bdalpe commented Jul 19, 2025

What this PR does / why we need it:

This PR improves the resource tailscale_device_subnet_routes behavior in two key ways:

  1. Force Resource Recreation on device_id Change
    Added ForceNew: true to the device_id schema field to ensure the resource is recreated when the device ID changes.

  2. Graceful Handling of Missing Devices
    Updated resourceDeviceSubnetRoutesRead to check for a 404 response from the API. If the device no longer exists, the resource ID is cleared to allow Terraform to recreate it instead of failing the plan.

Which issue this PR fixes (use fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged):

Fixes #526

Special notes for your reviewer: N/A

@mpminardi
Copy link
Member

@bdalpe thank you for the PR! Are you able to squash your commits and adjust the resulting commit message to follow https://github.com/tailscale/tailscale/blob/main/docs/commit-messages.md?

The DCO failure can be resolved by doing a git commit -s or git commit --amend -s to sign off the commit once this is done.

@bdalpe bdalpe force-pushed the bug/526-resource-subnets branch from 099d5f6 to 2878650 Compare August 12, 2025 13:12
…eSubnetRoutesRead

Reset resource id to force recreation when resourceDeviceSubnetRoutesRead receives a 404 status code

Fixes tailscale#526

Signed-off-by: Brendan Dalpe <[email protected]>
@bdalpe bdalpe force-pushed the bug/526-resource-subnets branch from 2878650 to a6ac885 Compare August 12, 2025 13:13
@bdalpe
Copy link
Author

bdalpe commented Aug 12, 2025

Hey @mpminardi, this should be fixed now. Let me know if you need any other changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tailscale_device_subnet_routes resource fails to update when previous device_id no longer exists
2 participants