Serverless Applications with AWS Lambda
Claudio Canales
Senior DevOps Engineer


Model push
Model poll

Kolejka (Amazon SQS)
Strumień (DynamoDB Streams)

{
"Records": [{
"messageId": "abc-123",
"body": "{\"order_id\": \"A-42\"}"
}]
}
Records.messageId oraz ciąg body.body do własnego ładunku.def lambda_handler(event, context):
records = event.get("Records", [])
for record in records:
body = record.get("body", "")
print("BODY:", body)
return {"statusCode": 200}
Records z domyślną pustą listą.body.import json
def lambda_handler(event, context):
record = event.get("Records", [])[0]
payload = json.loads(record.get("body", "{}"))
order_id = payload.get("order_id")
print("ORDER_ID:", order_id)
return {"statusCode": 200}
json i odczytaj body z bezpieczną wartością domyślną.json.loads, aby uzyskać słownik.ApproximateAgeOfOldestMessage pod kątem zaległości.




def lambda_handler(event, context):
failures = []
for record in event.get("Records", []):
try:
process(record)
except Exception:
failures.append({"itemIdentifier": record["messageId"]})
return {"batchItemFailures": failures}
messageId nieudanych rekordów w batchItemFailures.
Serverless Applications with AWS Lambda