Creating the Start Stop ec2 instances as lambda function
- Lets Create an IAM role for lambda to start or stop ec2 instances
- Lambda function to start ec2 by tag
- Lambda function to stop ec2 by tag
- Now lets call these functions based on schedule
- Every weekday on 10 AM we start the ec2 instances
- Every weekday on 7 PM we stop the ec2 instances
- For this we need to create an Event Bridge to create rule for ec2_start and ec2_stop
- Exercise:
- Create a role for aws lambda to have ec2 full access and cloudwatch full access.
- Create an ec2 instance and add a tag env & value qa
- NOw create a lambda function with code Refer Here
- Try to use Test Event to start or stop ec2 instance which you created.
- Optional: try to create a lambda function which stops the rds instances by their tag Refer Here