AWS Lambda - Hidden Treasures (I)
Images Credit of Respective authors, I have tried to use standard AWS/MS Icons

AWS Lambda - Hidden Treasures (I)

More you dive deeper into AWS Lambda, more you get awed at the fantastic work done by the dev team behind Lambda. For frugal architects who want to scale-out horizontally on-demand, AWS Lambda is a delight.

This post is about providing customer parameters at the invoker level (not config). Every Lambda can be triggered by multiple types of events and multiple events including Cloudwatch Events which we used as a scheduler. Cloudwatch Events can in-turn trigger multiple targets (up to 5) and the supported variety of target types is awesome!

No alt text provided for this image

We have used Lambda + Cloudwatch Events + Microsoft Teams to design a small SRE concept where Cloudwatch event fires an event every 30 mins that trigger's a Lambda which talks to an API to get some details, formats the data and then posts them to a Teams channel.

There was a need to compare the day end snapshot with the previous day. We decided to create another Channel but wanted to reuse the Lambda code. Following served our purpose beautifully:

Cloudwatch Events >> Edit Rule >> Targets >> Configure Input >> Constant (JSON Text)

So we configured two Events/Rules and passed a JSON object with different values {invocationtype:perodic} and {invocationtype:dayend}

No alt text provided for this image

Inside the Lambda Function Handler, Stream was good enough to tell the Lambda which event invoked the Lambda to decide which channel to post to.

public string FunctionHandler(Stream input, ILambdaContext context)
        {

The concepts in this post are very simple once you know them, but when they work together, they add tremendous value and at a very reasonable price point.

  #aws #lambda #cloudwatchevents #msteams 

要查看或添加评论,请登录

Manish Jain的更多文章

社区洞察

其他会员也浏览了