Lambda

Lambda provides you the capability to write your business logic code in the form of lambda functions that can be used/executed via API Gateway or Schedules. Think of it like the functions/methods that are written in the service layer of a backend application to interact with databases and execute business logic.

To create a Lambda Function just go to Code > Lambda and click on Add New. Enter the basic details - Name, Description, Interpreter & Docker Image - pymongo (Refer Lambda Runtime Section for creating docker runtime images) & select runtime memory accordingly.

Code > Lambda > Add New

In this example, we will fetch data from MongoDB that is being created by Bidata Pipeline. Get the MongoDB connection details from Market Place > MongoDB and use the same in Lambda code to connect to MongoDB.

Add a new parameter in the upper right corner of the screen to pass it into the lambda function when it will be called.

Code > Lambda > Parameters

Write your MongoDB code in the available main function to get data for a specific device id which can be passed into the function using parameters, all the parameters will be available in the args variable of the main function.

Code > Lambda > Create

Once you are done with the code then save the details, and navigate to the Lambda List page.

Code > Lambda

To test the functionality of this lambda function click on {} Invoke button available in actions of Lambda. Then click on Try It Out and click on Execute button, wait for a few seconds to see the output in the Result tab.

Code > Lambda > Invoke

Last updated