diff --git a/integration-kinesis-to-lambda/main.py b/integration-kinesis-to-lambda/main.py new file mode 100644 index 0000000..26cacdc --- /dev/null +++ b/integration-kinesis-to-lambda/main.py @@ -0,0 +1,13 @@ +import base64 +def lambda_handler(event, context): + + for record in event['Records']: + try: + print(f"Processed Kinesis Event - EventID: {record['eventID']}") + record_data = base64.b64decode(record['kinesis']['data']).decode('utf-8') + print(f"Record Data: {record_data}") + # TODO: Do interesting work based on the new data + except Exception as e: + print(f"An error occurred {e}") + raise e + print(f"Successfully processed {len(event['Records'])} records.") diff --git a/integration-kinesis-to-lambda/snippet-data.json b/integration-kinesis-to-lambda/snippet-data.json index cff00d9..cf24999 100644 --- a/integration-kinesis-to-lambda/snippet-data.json +++ b/integration-kinesis-to-lambda/snippet-data.json @@ -3,7 +3,7 @@ "description": "Using AWS Lambda with Amazon Kinesis without Batch Item Handling.", "type": "Integration", "services": ["lambda", "kinesis"], - "languages": ["Node", "TypeScript", ".NET", "Java", "Go"], + "languages": ["Node", "TypeScript", ".NET", "Java", "Go", "Python"], "tags": [], "introBox": { "headline": "How it works", @@ -74,6 +74,17 @@ "language": "go" } ] + }, + { + "id": "Python", + "title": "Usage Example with Python", + "description": "Consuming Kinesis event with Lambda using Python without batch item handling.", + "snippets": [ + { + "snippetPath": "main.py", + "language": "python" + } + ] } ] } @@ -101,6 +112,13 @@ "image": "https://pbs.twimg.com/profile_images/888727786797412352/DEZ1mRjs_400x400.jpg", "bio": "Solutions Architect Architect at AWS", "linkedin": "ananthanr" + }, + { + "headline": "Python Example Presented by Umang Aggarwal", + "name": "Umang Aggarwal", + "image": "https://media.licdn.com/dms/image/D5603AQGPJSLqUSGPmA/profile-displayphoto-shrink_800_800/0/1684261011000?e=1707350400&v=beta&t=YoDvcLUA8y_w5ZAq0p6wDNL5nut8PVKCUvrf6rTi43A", + "bio": "Cloud Support Engineer at AWS", + "linkedin": "umangaggarwal" } ] -} +} \ No newline at end of file