Serverless Applications with AWS Lambda
Claudio Canales
Senior DevOps Engineer







Records is the batch.body is a string.messageId helps you trace and deduplicate.def lambda_handler(event, context):
records = event.get("Records", [])
for record in records:
body = record.get("body", "")
print("BODY:", body)
return {"statusCode": 200}

import json
def lambda_handler(event, context):
records = event.get("Records") or [{}]
body = records[0].get("body", "{}")
payload = json.loads(body)
oid = payload.get("order_id")
return json.dumps({"order_id": oid})
body is a string; parse it with json.loads."{}".order_id and return JSON with json.dumps.

.get() and defaults for optional fields.
messageId or order_id.

Serverless Applications with AWS Lambda