-
Notifications
You must be signed in to change notification settings - Fork 8
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
Removal of device from Tailscale upon EC2 instance termination #22
Comments
@oeed that would be awesome and we'd be all for it. We have this same problem with our own AMI auto-update automation. Sadly, I don't know off the top of my head how we can easily solve this. Is there a termination hook script that can be executed for EC2 instances? |
I haven't done it personally before, but in doing some research it does seem like ASG lifecycle management hooks would be suitable for this: https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html It does seem fairly straight forward to declare, and then you can simply put the script in user_data. resource "aws_autoscaling_lifecycle_hook" "termination_hook" {
name = "instance-termination-hook"
autoscaling_group_name = aws_autoscaling_group.example.name
default_result = "CONTINUE"
heartbeat_timeout = 300
lifecycle_transition = "autoscaling:EC2_INSTANCE_TERMINATING"
} This is what Claude suggested, but obviously can't vouch for how accurate it is: https://claude.site/artifacts/251c7774-b974-4a5b-ad54-3582796bfc2d |
@oeed very cool and a good use of AI. Claud does make that seem kinda simple... Little bit worried about that being the default experience, but if it was enabled by the module consumer than I'd be all for it. Would you be interested to contribute this functionality? We can kick the tires and test it out prior to merging if so. |
Discussing this internally at Masterpoint and @gberenice was already aware of this issue. She shared this issue from the TS provider which is worth tracking as well: tailscale/terraform-provider-tailscale#68 |
@oeed -- @gberenice is going to add a |
Okay great! I'll probably be freed up in about a week to contribute, so if there is something you'd like to me to do just let me know. |
@oeed I've tried to test extra flags, and came up with the conclusion, that the best way is just to set the variable Ephemeral nodes are supposed to be short-lived devices, and I have some doubts if it's a good choice for a subnet router. We're going to test it for a while on the customer of ours before we can strongly recommend this approach. |
Thanks again for this great module!
We have an SSM automation that automatically updates the launch template with the latest AMI image every week to automatically stay on top of Inspector alerts. As a result, over time Tailscale is left with old machines (i.e. previously terminated EC2 instances) in the list. It also means the replacement machines have a
-2
,-3
, etc. suffix rather than the desired name.What would be awesome is an automatic cleanup script in the launch template that automatically removes the machine from Tailscale upon termination.
The text was updated successfully, but these errors were encountered: