How to Achieve 60% AWS Cost Optimization with Terraform, Functions, and Tags?

Inventory Optimization

Introduction

We’re experts in AWS cost optimization(saving money. One of our clients, an Edutech company, was having trouble keeping costs down as they added more infrastructure. They’re a fast-growing company with lots of users on their education platform. But as their business grew and they used more AWS services, keeping costs in check became a big problem. They came to us for help. After looking into it, we found they were using on-demand instances for their testing area, and these were running even after work hours and weekends. Also, they were using Elastic IP for it. Plus, many machines were running during off-peak hours in their production setup.

To fix these problems, we suggested two plans:

  1. Use Serverless functions and tagging to stop machines automatically when they’re not needed, like after work or during quiet times.
  2. Use spot instances for your testing and staging areas.

This blog explains how using Serverless functions and tagging can help save money on AWS bills by shutting down machines when they’re not in use, especially on weekends and after hours.

The challenge we faced and its solution

Identifying Off-Peak Hours for AWS Cost Optimization

To tackle the cost optimization challenge, we analyzed its website traffic patterns using AWS CloudWatch metrics and logs. We discovered that their peak customer activity occurred during specific hours, primarily during weekdays. Outside these peak hours, the website experienced significantly lower traffic and resource utilization. This observation presented a prime opportunity for cost reduction by leveraging serverless functions and resource tagging effectively.

Business Solution

AWS Cost Optimization

Resource Tagging for Enhanced AWS Cost Management

An Edutech company recognized the importance of resource tagging to gain granular visibility into their AWS expenses. They strategically assigned tags to their resources, including EC2 instances, RDS databases, and S3 buckets. The tags provided essential metadata that helped in identifying and classifying resources based on their usage, importance, and department ownership.

By leveraging resource tags, Edutech company could generate accurate cost reports using AWS Cost Explorer. They could identify resource-wise cost breakdowns and gain insights into areas where expenses could be reduced. For instance, by analyzing the costs associated with specific tags, such as “development,” “testing,” or “staging,” the company could identify idle or underutilized resources during off-peak hours and take appropriate action to optimize costs.

Find the solution on our GitHub link.

Schedule timing to automatically start and stop the EC2 Instances for the AWS Cost Optimization

Many businesses are focused on lowering the costs of running AWS EC2 instances. Terraform can help you save money by automating EC2 instance management. This solution enables you to automate the start and stop of your instances based on your business requirements. It automates the scheduling of EC2 instances, leveraging CloudWatch events, for efficient starting and stopping based on specified cron expressions, optimizing resource utilization, and reducing costs.

Non-production machines can be turned off after hours and on weekends. The machines can be started whenever working hours begin. This might result in more than 50% of your ec2 instances being stopped, saving you a lot.

Find the solution on our GitHub link.

Serverless Function for the AWS Cost Optimization

We utilize serverless functions to provide endpoints where developers can access machine IP addresses and initiate start and stop actions as necessary. This eliminates the need for Elastic IPs and decreases costs. Additionally, developers can manage instances without console access, enhancing efficiency and security.

Find the solution on our GitHub link.

Results and Benefits

By adopting serverless functions and resource tagging, Edutech company achieved significant cost reductions during off hours and weekends. The following highlights the outcomes of their cost optimization efforts:

  1. Reduced EC2 Instance Costs: By offloading non-critical tasks to serverless functions, an Edutech company minimized the need to run and maintain EC2 instances 24/7, substantially reducing EC2 costs during off-peak hours.
  2. Eliminated Idle Resources: Leveraging resource tagging and cost reports, an Edutech company identified idle resources during off hours and took corrective measures. They terminated or downsized underutilized instances and databases, reducing unnecessary expenses.

Additionally, they reduced their AWS expenses by up to 60% without impacting their application’s performance or availability. The serverless architecture allowed them to scale resources on demand and pay only for the computing power they used. The tagging strategy improved their cost-tracking capabilities and enabled them to make data-driven decisions to optimize their infrastructure further.

Conclusion

Optimizing AWS expenses can be challenging, especially for organizations managing complex infrastructures and variable workloads. However, the Edutech Company effectively reduced costs during off-hours and weekends by utilizing serverless functions, implementing comprehensive tagging strategies, and leveraging Terraform for automation. This approach resulted in a remarkable 60% reduction in AWS expenses.

Thank you for Reading !! 🙌🏻😁📃, see you in the next blog.🤘

I hope this article proves beneficial to you. In case of any doubts or suggestions, feel free to mention them in the comment section below or directly contact us.

The end ✌🏻

“If you’re facing migration issues and need our help, don’t hesitate to contact us for a free consultation.”

References