Created
March 23, 2022 16:34
-
-
Save rafael-gumiero/1a030bfa3e8f314c96437287168f1dfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import base64 | |
| import json | |
| print('Loading function') | |
| def lambda_handler(event, context): | |
| output = [] | |
| for record in event['records']: | |
| print(record['recordId']) | |
| payload = base64.b64decode(record['data']).decode('utf-8') | |
| reading =json.loads(payload) | |
| # Add additional column source | |
| reading['source'] ='NYCTAXI' | |
| # Do custom processing on the payload here | |
| output_record = { | |
| 'recordId': record['recordId'], | |
| 'result': 'Ok', | |
| #'data': base64.b64encode(payload.encode('utf-8') | |
| 'data' : base64.b64encode(json.dumps(reading).encode('UTF-8')) | |
| } | |
| output.append(output_record) | |
| print('Successfully processed {} records.'.format(len(event['records']))) | |
| return {'records': output} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment