Member-only story

AWS Serverless: How to Stop EC2 using Event Bridge and Lambda

Praveen Sambu
3 min readDec 17, 2024

--

#lambda#aws#eventbridge#serverless

“Just like you wouldn’t leave all the lights on while sleeping, why keep your EC2 servers running when they’re not in use?”

In this article, I will demonstrate how to stop EC2 instances using Amazon EventBridge and AWS Lambda on a scheduled basis.

Introduction:

With the cloud, launching EC2 instances to host and run your applications is incredibly easy. You might use these instances for development, testing, production, failover, disaster recovery (DR), proof of concept (PoC), or a variety of other reasons — unless you are fully committed to a serverless architecture! Over time, a company may accumulate hundreds of EC2 instances, and the cost can escalate quickly.

With the convenience of the cloud comes the Shared Responsibility Model, where AWS manages the infrastructure, but customers are responsible for managing resource usage and costs. That’s where FinOps (Cloud Financial Management) becomes crucial. One of the best practices is to understand usage and costs for your cloud resources.

In the context of managing numerous EC2 instances, it’s essential to analyze whether all of them need to be running 24/7. Most likely, your analysis will reveal that certain instances are only required during specific periods.

Use Case:

--

--

Praveen Sambu
Praveen Sambu

Written by Praveen Sambu

Software Engineer |AWS Community Builder |Technical Blogger | Trainer . Founder of Cloud In Detail (https://cloudindetail.com/) still working on building blog…

No responses yet