SOLUTION of the MONTH:
How to automatically shut down EC2 instances outside business hours
by High Order Solutions
Our AWS account budget started small but over the years has grown into something quite substantial. In the beginning it was just our mail server, our public website, and our Atlassian Suite server. Easy peasy. But since then, we’ve added a sand box Atlassian server for testing, the occasional Dev Atlassian server for development projects, our CRM server, our MarCom Contact Mgmt server, a database instance, a DevOps instance, an Ansible automation server and all the load balancers, S3 buckets, and monitoring tools to manage it all. And this wasn’t cheap. It just sort of creeped up on us.
If only we could remember to turn off the instances we didn’t always need and just create instances on demand from previously designed AMI’s.
Today’s solution is just about the turning stuff off.
You’ll need knowledge in these areas as well:
- Setting up IAM accounts with very limited, but powerful, permissions
- How to use CloudWatch to setup the events that will trigger your Lambda Functions
- A thorough understanding of CRON (jobs) Expressions
AWS Lambda to the Rescue!
Aside from our website and application servers we seldom have need for many of our other EC2 instances outside business hours. Especially our testing environments like those use for User Acceptance Testing, Sandboxing, or Dev. If we could automate turning off & on these instances from 7pm to 7am during the work week PLUS the entire weekend we could save a ton. Given we only need them running Monday thru Friday 7a to 7p, 12 hours each day, we could save approximately 108 hours of the 168 hour calendar week. 168 – 60 = 108. That’s a 64% savings!
Why this solution?
- No servers to manage – Like a separate Ansible Server
- Continuous scaling – We can keep adding to it’s capabilities
- Cost optimized with millisecond metering – Only costs us money when it’s running
- Consistent performance at any scale
For more information on these reasons, check out https://aws.amazon.com/lambda/
Don’t forget that you’re working in GMT time, so make your conversions carefully.
Take-Aways & Lessons Learned:
If managed properly, an organization can automate many repetitive AWS tasks for consistency and to help you stay within budget.
How Does it Work?
Download Complete Instructions Here
Don’t worry, we’re not going to ask for your personal information or trick you into talking to a salesperson first. We REALLY hate that too.
NOTE: THESE INSTRUCTIONS ARE PROVIDED AS GUIDANCE FOR TRAINING PURPOSES ONLY. DO YOUR OWN RESEARCH AND TESTING.
IN NO EVENT SHALL THE COMPANY OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING WITHOUT LIMITATION, SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR INDIRECT DAMAGES FOR PERSONAL INJURY, LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, OR ANY PECUNIARY LOSS) ARISING OUT OF THE USE OF THIS PRODUCT OR THESE MATERIALS, EVEN IF THE COMPANY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.