Invoke Lambda based on Kinesis records Partition Key

那年仲夏 提交于 2019-12-11 13:59:01

问题


I have different Types of data flowing in through my kinesis streams. Each of the record has a different partition key. I need to invoke a lambda function only if a record with certain partition key in added to the stream. Is there a way to specify that the lambda would be triggered only if a partition key "a" is encountered rather than invoking a lambda and then checking the partition key?


回答1:


It's more kind of a Design Question, I don't know if you can configure this. But you can always use Lambda Chaining using SNS.

Lambda Fuctions with SNS

Create SNS topic for each of your Partition Key and configure your Lambda on them respectively, then You can create one Parent Lambda function which can get Partition key and Object. And publish those object to the respective SNS topics.




回答2:


You can either use an SNS topic where you push only records that have a certain partition key and then connect another lambda function to that topic that processes the records.

Another option would be to asynchronously re-invoke your lambda function. The benefit is that you don't need another component (i.e., no SNS topic).

How this would work is basically that you check in your function if the partition key is "a" and if it is, re-invoke the function asynchronously with the record and a specific parameter that indicates that the record should be processed.

You can read more about how this can be done here: https://engineering.dubsmash.com/implementing-real-time-analytics-using-aws-kinesis-lambda-1ea56f10e473



来源:https://stackoverflow.com/questions/37921844/invoke-lambda-based-on-kinesis-records-partition-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!