Automating AWS Instances for Cost-efficiency: A Guide to Instance Scheduler

Automating AWS Instances for Cost-efficiency: A Guide to Instance Scheduler

Teleperformance - 04.19.2024

Miguel Gomez Hernandez - Cloud Center of Excellence

Managing your Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Relational Database Service (Amazon RDS) instances efficiently can lead to significant cost savings. AWS Instance Scheduler is a powerful solution that automates the starting and stopping of instances, allowing you to trim operational costs and ensure effective resource utilization.


What are the key benefits of scheduling instances?

  1. Cost reduction. Automating the shutdown and startup of instances contributes to monthly billing reductions, providing cost savings on low-usage instances.
  2. Effective use of instances. Schedule instance usage based on your working hours, ensuring they are available when needed. This is particularly useful for non-productive workloads such as development and testing.
  3. Avoid manual actions. With automated configuration, you can eliminate errors related to manual status changes, unexpected shutdowns, and other human errors.


Instance scheduler features


The automatic startup and shutdown solution offers the following features for better control and management of your AWS instances:

  1. Cross-account Instance Scheduling
  2. Automated Tagging
  3. Configure Schedules with Scheduler CLI
  4. Infrastructure as Code (IaC) Support
  5. Integration with SSM Maintenance Windows
  6. Integration with AppRegistry and AWS Systems Manager Application Manager


How does the solution work?


The solution utilizes an AWS CloudFormation template to create an automated structure for scheduling instances. Here's a high-level overview of the process:

 


The Instance Scheduler on AWS initiates the deployment of an Amazon EventBridge event bus when the user opts for the CloudFormation parameter "Use AWS Organizations." If chosen, the Amazon EventBridge diagram in the Instance Scheduler deployment only displays the event bus, an additional component beyond the resources already depicted.


Here's an overview of the key steps in the high-level process flow for the solution components established through the AWS CloudFormation templates:

  1. Configuration. The CloudFormation template sets up an Amazon CloudWatch event at user-defined intervals. This event triggers the Instance Scheduler AWS Lambda function, configured with regions, accounts, and a custom tag.
  2. DynamoDB Storage. Specified values are stored in Amazon DynamoDB, retrieved by the Lambda function during execution. Users can apply the custom tag to relevant instances.
  3. Tagging instances. During setup, a tag key is defined to identify applicable Amazon EC2 and Amazon RDS instances. The tag value links to the schedule intended for the resource.
  4. AWS organizations integration. Optionally, users can enable AWS Organizations. If selected, an additional Event Bus resource is generated to receive events from CloudWatch events in remote accounts.

 

The Lambda function, utilizing AWS Identity and Access Management (AWS IAM) and AWS Key Management System (AWS KMS), checks the state of instances against the targeted state defined in the schedule. It then takes appropriate start or stop actions. The Lambda function logs relevant information, including schedule name, instance count, and running instances, as an optional custom metric in Amazon CloudWatch.


By leveraging AWS Instance Scheduler, you can streamline your instance management, reduce costs, and ensure optimal resource utilization for your AWS environment.


Learn more about our technology services that innovate as​ you do by clicking  here.

Image Linkedin
Image Twitter
Image Facebook
Image Email
Image Share