Member-only story
Cost Optimization on AWS EC2 and Database Instances Using AWS Lambda and Amazon EventBridge - 2
We know very well that “The Cloud = Pay for what you use”. Thus, it can be expensive to run Amazon EC2 instances continuously. By scheduling your instances’ start and stop times, you can ensure that you only pay for the computing resources you need. This solution helps reduce operational costs by stopping resources that are not in use and starting resources when their capacity is needed. For example, if you want to automatically stop instances outside of business hours every day and turn them on automatically at the start of work at work. This solution can result in up to 70% cost savings for those instances that are only necessary during regular business hours (weekly utilization reduced from 168 hours to 50 hours) (1). Or you are doing research and want your EC2 to shut down automatically when you are not working, Or there is a website that announces the exam results of a school, you want the website’s EC2 or database instances to be active after the exam results are determined. The topic we will talk about today is suitable for use in these and various similar scenarios. We will do these subjects practically (Hands-on) and step by step.
In this article, we will create two EventBridge rules that run our Lambda functions. Finally, we will test the running of EventBridge rules and Lambda Functions on the EC2 instance. We will see that the EC2 instances start and stop at the time that we want and set up.
Topics we covered in the first part of the article series;
1. What are AWS Lambda and Amazon EventBridges?
1. a. AWS Lambda
1. b. Amazon EventBridges
2. Creating IAM Policy
3. Creating IAM Role for Lambda
4. Creating EC2 Instances to Test
5…