-
Notifications
You must be signed in to change notification settings - Fork 48
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
The tailscale_tailnet_key
resource should handle expired keys
#144
Comments
Agreed that this should be addressed. It is a bit tricky in that the API key which issues the auth key also has a 90 day expiration and may also be expired. Work on tailscale/tailscale#3243 is underway now, to provide an automatable workflow where API keys won't expire and require manual intervention. We'll update this provider to use that mechanism when it is available. |
Currently, the provider handles a 404 returned from the API when the key is non-reusable here: The fact that reusable keys expire naturally does cause an issue, but I think the best way to work with this is to use the resource "time_rotating" "tskey" {
rotation_days = 30
}
resource "tailscale_tailnet_key" "tskey" {
reusable = true
preauthorized = true
lifecycle {
replace_triggered_by = [time_rotating.tskey]
}
} The above will ensure that the first apply after 30 days will recreate the key. |
Alternatively, if you're using HashiCorp Vault as part of your stack also, there are a couple vault plugins for issuing tailnet keys: https://github.com/bloominlabs/vault-plugin-secrets-tailscale |
FYI @davidsbond, there's currently a bug (hashicorp/terraform-provider-time#118) in the There's an additonal suggested workaround hashicorp/terraform-provider-time#118 (comment) |
I ran into a related issue. If you set |
@DentonGentry @!davidsbond this seems related to #198, not sure which ya'll want to keep open. Now that tailscale/tailscale#3243 is implemented and closed, any chance to move this major issue forward? Right now my team is dealing with via a recurring calendar event that attempts to remind us to rotate the key... definitely not my favorite thing 😁 [edited Mar 1, 2023 by DentonGentry to remove the @-mention of davidsbond, who developed this provider but has handed off ongoing support for Tailscale to handle] |
I have created a PR #221 that adds a new field, where you can add a |
This doesn't seem to work with what's being suggested, even when the key is set to never expire. |
As the
@Gowiem - this might avoid the manual intervention for you. |
|
It's because even replacement requires Terraform to try and refresh the state of the existing resource, before deciding what action to take. The code currently checks |
Updates tailscale/terraform-provider-tailscale#144 Signed-off-by: Anton Tolchanov <[email protected]>
Updates tailscale/terraform-provider-tailscale#144 Signed-off-by: Anton Tolchanov <[email protected]>
Updates tailscale/terraform-provider-tailscale#144 Signed-off-by: Anton Tolchanov <[email protected]>
Updates tailscale/terraform-provider-tailscale#144 Signed-off-by: Anton Tolchanov <[email protected]>
Updates tailscale/terraform-provider-tailscale#144 Signed-off-by: Anton Tolchanov <[email protected]>
We've discovered in #306 that this change had a side effect of making Terraform recreate single-use keys, which may result in other resources that use the key being updated/replaced. I am thinking of reverting the change to go back to the historic behaviour (ignore invalid keys), adding a new |
Updates tailscale/terraform-provider-tailscale#144 Signed-off-by: Anton Tolchanov <[email protected]> Signed-off-by: Alex Paguis <[email protected]>
Describe the bug
A few months after generating a few
tailscale_tailnet_key
resources in my terraform code, those keys expired in tailscale control and were subsequently deleted by the api. Now when I run my Terraform again after the keys have expired, the provider fails to fetch these keys and blocks my Terraform deployment.To Reproduce
Steps to reproduce the behaviour:
tailscale_tailnet_key
withreusable = true
Expected behaviour
The provider detects an expired key by evaluating that the expire time/date in state is less than the current time/date and that the resource is a 404 response from the api, removes the resource from state, then a plan is calculated to recreate the resource to ensure the desired end state.
Desktop (please complete the following information):
Additional context
This is similar to an issue brought up in #59 where keys would vanish from the API, except due to
reusable = false
The text was updated successfully, but these errors were encountered: