-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda_function
More file actions
26 lines (23 loc) · 788 Bytes
/
lambda_function
File metadata and controls
26 lines (23 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import json
import boto3
firehose_client = boto3.client('firehose')
def lambda_handler(event, context):
print("Init")
resultString = ""
for record in event['Records']:
parsedRecord = parseRawRecord(record['dynamodb'])
resultString = resultString + json.dumps(parsedRecord) + "\n"
print("resultString:" + resultString)
response = firehose_client.put_record(
DeliveryStreamName="OrdersAuditFireHose",
Record={
'Data': resultString
}
)
print("Success")
def parseRawRecord(record):
result = {}
result["orderId"] = record['NewImage']['orderId']['S']
result["state"] = record['NewImage']['state']['S']
result["lastUpdatedDate"] = record['NewImage']['lastUpdatedDate']['N']
return result