AWS Lambda


AWS_lambda.png
AWS Lambda is a serverless computing service that allows you to run code in response to events without managing services.

It enables us to write functions that are triggered by specific events, such as HTTP Requests, changes in a database, or incoming data from services.

Lambda automatically scales in response to the volume of requests, meaning you only pay for the compute time you use, making it cost-effective and efficient.


Benefits of using AWS Lambda in IoT Applications


Key Components of an AWS Lambda Function



AWS_lambda_workflow.png

  1. In our IoT system, AWS Lambda functions serve as the main processor of incoming data from IoT devices, such as temperature or humidity readings.
  2. A Lambda function can be triggered by API Gateway when a device sends an HTTP POST request with sensor data. The function can:
    1. Parse the JSON payload from the request.
    2. Extract the sensor data (e.g., temperature, humidity, timestamp).
    3. Store the data in DynamoDB for long-term storage and analysis.
Note

Another Lambda function can retrieve data when an HTTP GET request is made (e.g. /data/latest).

This function queries DynamoDB for the latest record associated with a device.