AWS loves to talk about the economics of Infrastructure as a Service, and “turn CapEx into OpEx” is one of their favorite tag lines. I’m not here to tell you about public, private, and hybrid options, but let’s talk about saving money for a second. Paying for what you use can save you money, but if you use EC2 you can be saving even more by paying for what you will use in the future.
I’m talking about Reserved Instances, paying up front for one or three years of usage for an instance. By reserving capacity, you can save up to %56 depending on the instance type, term length, and payment option. Cutting compute costs by half is great, but it does take some extra work. You need to purchase reservations separately and make sure you buy new reservations when existing ones expire.
Fortunately, by scheduling a Lambda function you can get emails when reservations are close to running out. The Sheepherding project provides a reserved_instance_report.py function to do just that. It uses Simple Email Service (SES) to send email reports about reservations for your account.
What’s in the email?
- A list of reservations that have expired in the last 10 days
- A “Red Alert” list of reservations expiring in the next 30 days
- An “Orange Alert” list of instances expiring in the next 6 months
That covers everything you need to stay on top of your RI’s, and the number of days is configurable for each alert type if six months is too far in advance for you to worry.
Deploying is easy, you can schedule the reports the same way we scheduled
EBS snapshots to be taken daily. In this case, you’d probably want to
switch to a weekly frequency so you don’t annoy yourself.
reserved_instance_report.py
doesn’t have any dependencies other than what’s
available by default in the Lambda execution environment, so you can paste the
code right into the web interface.
Thanks for reading, as always you can drop me a line at ryan@serverlesscode.com or keep up with new posts via RSS and email.