This article provides a solution for automating the shutdown of Lightsail for Research virtual computers when they reach a specific budget threshold.
Background
Lightsail for Research (LfR) users are often budget focused. This may be due to limited funding, or because a researcher is leveraging a specific grant. LfR provides built-in functionality to optimize costs when resources go idle, but it doesn't allow users to set a specific budget threshold. LfR users often inquire about ways to ensure they don't exceed their desired budget amount.
Lightsail for Research budget shutdown sample solution
The LfR budget shutdown sample solution allows users to specify a budget threshold and time period that the threshold covers. If this budget threshold is reached during the specified time period, the LfR virtual computer will be stopped. Keep in mind that while data storage costs will still be incurred, the hourly charge for the virtual computer will not.
You can find the CloudFormation template for this solution in our GitHub repository: Lightsail for Research budget shutdown repository.
Usage

Figure 1: CloudFormation template parameters for setting budget threshold and time period
As shown, the setup is minimal and requires only a few parameters to deploy. You need to provide the designated budget threshold, time period, LfR virtual computer name, and its associated region. You will also provide your email for alerting when a threshold is met. If a budget changes, the user can simply update the parameter within the deployed CloudFormation template.
Conclusion
Since budget actions cannot currently target Lightsail for Research virtual computers, this sample solution closes that gap by allowing users to automate shutdown actions based on budget events. This solution provides researchers with greater control over their spending and helps ensure they stay within their allocated budgets.