AWS Lambda Integration With EventBridge
In our previous blog, we explored the concept of Lambda versioning. In real-world scenarios, Lambda functions are typically triggered either on a schedule or in response to specific events. In this post, we’ll walk through how to invoke a Lambda function using both scheduled triggers and event-driven mechanisms.
This is our goal. Our lambda scans for any RUNNING, PENDING instances of type "T3.SMALL". If there are any instances of that type, it triggers an email.
Involved services:
1) Lambda - Python code to scan for RUNNING, PENDING instances of type "T3.SMALL"
2) Event Bridge - Scheduler and Event Based.
3) SNS - Notification Service.
Here is the simple lambda code:
Now we have our lambda function ready. Lets create event bridge scheduler.
Under target section, I am pointing to the lambda function I deployed.
Finally, We create a SNS - Topic with email as the protocol and confirm the subscription.
From our schedule, the lambda is invoked for every 5 minutes and if condition matches it triggers an email. Let's test it by creating EC2 instances of type "T3.SMALL"
The instance ID's are matching with the email.
Comments
Post a Comment