【发布时间】:2023-01-02 00:50:51
【问题描述】:
我正在尝试跟踪 DynamoDB 表中的事件触发 Lambda 函数,该函数将事件移至 Kinesis Data Firehose。然后,Kinesis 对文件进行批处理并将它们发送到 S3 存储桶。我用作触发器的 Lambda 函数失败。
这是触发器的 Lambda 代码:
```
import json
import boto3
firehose_client = boto3.client('firehose')
def lambda_handler(event, context):
resultString = ""
for record in event['Records']:
parsedRecord = parseRawRecord(record['dynamodb'])
resultString = resultString + json.dumps(parsedRecord) + "\n"
print(resultString)
response = firehose_client.put_record(
DeliveryStreamName="OrdersAuditFirehose",
Record={
'Data': resultString
}
)
def parseRawRecord(record):
result = {}
result["orderId"] = record['NewImage']['orderId']['S']
result["state"] = record['NewImage']['state']['S']
result["lastUpdatedDate"] = record['NewImage']['lastUpdatedDate']['N']
return result
```
目标是让 lambda 函数将事件移动到由 DynamoDB 中的事件触发的 Kinesis
【问题讨论】:
-
您的 Lambda 函数日志说了什么?这就是写入错误的地方。
标签: amazon-web-services lambda amazon-dynamodb amazon-kinesis amazon-dynamodb-streams