AWS Cost Optimization: How We Cut EC2 Costs by 50%
A serverless, tag-driven AWS Cost Optimization strategy that eliminated 40+ idle EC2 instances for a growing EdTech platform, with zero manual intervention.
Every DevOps team eventually hits the same wall: infrastructure that runs around the clock, whether anyone is using it or not. That was exactly the challenge facing an EdTech company we recently partnered with. Our AWS Cost Optimization engagement helped them cut non-production EC2 costs by 50%, automate lifecycle management across 40+ resources, and remove manual intervention entirely, all without touching engineering capability.
The Situation
The company’s user base was growing fast, and its infrastructure spend was growing faster. Testing and staging environments ran continuously through nights, weekends, and public holidays, even though nobody was actively using them outside working hours. The brief was clear: reduce the AWS bill without slowing engineering down.
The Problem Behind the Bill
A closer audit surfaced four issues driving the spend:
- Testing environments running 24/7. On-demand EC2 instances were needed for roughly 50 hours a week of active development but were running all 168.
- Idle Elastic IPs. IPs remained attached to stopped instances, incurring charges for resources nobody was using.
- No lifecycle management. No one owned the responsibility of shutting instances down at the end of the day.
- On-demand pricing for predictable workloads. Test environments sat on on-demand pricing instead of cheaper spot alternatives.
The Solution: A Three-Part AWS Cost Optimization Strategy
Strategy 1: Terraform and CloudWatch Events for Governance
We built a resource tagging layer across all EC2 instances using Terraform, then used CloudWatch Events with cron expressions to automate start and stop schedules. Tags such as Environment: test and AutoStop: true drive policy directly, so any new instance created with the right tags inherits lifecycle rules automatically. No extra setup required.
Strategy 2: Serverless Functions for Dynamic Control
Automation covers the routine, but development is not always routine. We deployed AWS Lambda functions as serverless endpoints engineers can call directly, no AWS console access needed, to start an instance for unplanned work or stop one early once work wraps up.
Strategy 3: Spot Instances for Test and Staging
Wherever interruption tolerance was acceptable, we migrated non-production workloads to EC2 Spot. Test environments, batch jobs, and CI/CD runners now run on Spot pricing instead of on-demand.
Technical Architecture
- IaC: Terraform, handling resource tagging and lifecycle policies
- Scheduling: AWS CloudWatch Events, cron-based start and stop
- Runtime control: AWS Lambda, serverless override endpoints
- Compute: EC2 Spot for test and staging, on-demand for production
- Governance: Tag-based policy across Environment, AutoStop, and Schedule
The Results
- 50% EC2 cost reduction in non-production environments
- 40+ resources eliminated from running outside working hours
- 100% automated instance lifecycle management
- Zero manual intervention required for scheduled start and stop
Engineering capability stayed fully intact. Developers can still override schedules on demand through the Lambda endpoints whenever unplanned work comes up.
Frequently Asked Questions
What is AWS Cost Optimization? AWS Cost Optimization is the practice of reducing cloud spend through right-sizing, automated scheduling, and pricing model choices such as Spot Instances, without reducing the performance or availability a team needs.
How much can EC2 lifecycle automation save on non-production environments? In this engagement, automated EC2 lifecycle management using Terraform, CloudWatch Events, and Lambda cut non-production costs by 50%, since test and staging instances stopped running outside actual working hours.
Do Spot Instances work for test and staging environments? Yes, for interruption-tolerant workloads like test environments, batch jobs, and CI/CD runners, Spot Instances offer substantial savings over on-demand pricing without affecting engineering output.
Facing a Similar AWS Cost Problem?
If your non-production environments are running around the clock, our DevOps automation services can help you build the same kind of tag-driven AWS Cost Optimization strategy. You can also see how we approach automation at scale in our LogiGPT case study.
Book a free consultation: https://cal.com/kapil-jain/30min