Skip to content

Commit 1d488e6

Browse files
authored
Merge pull request #100 from Umang-Aggarwal-07/main
Added Python Handler file for Lambda Kinesis Integration
2 parents 4f92047 + 00a6e6a commit 1d488e6

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

integration-kinesis-to-lambda/main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import base64
2+
def lambda_handler(event, context):
3+
4+
for record in event['Records']:
5+
try:
6+
print(f"Processed Kinesis Event - EventID: {record['eventID']}")
7+
record_data = base64.b64decode(record['kinesis']['data']).decode('utf-8')
8+
print(f"Record Data: {record_data}")
9+
# TODO: Do interesting work based on the new data
10+
except Exception as e:
11+
print(f"An error occurred {e}")
12+
raise e
13+
print(f"Successfully processed {len(event['Records'])} records.")

integration-kinesis-to-lambda/snippet-data.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Using AWS Lambda with Amazon Kinesis without Batch Item Handling.",
44
"type": "Integration",
55
"services": ["lambda", "kinesis"],
6-
"languages": ["Node", "TypeScript", ".NET", "Java", "Go"],
6+
"languages": ["Node", "TypeScript", ".NET", "Java", "Go", "Python"],
77
"tags": [],
88
"introBox": {
99
"headline": "How it works",
@@ -74,6 +74,17 @@
7474
"language": "go"
7575
}
7676
]
77+
},
78+
{
79+
"id": "Python",
80+
"title": "Usage Example with Python",
81+
"description": "Consuming Kinesis event with Lambda using Python without batch item handling.",
82+
"snippets": [
83+
{
84+
"snippetPath": "main.py",
85+
"language": "python"
86+
}
87+
]
7788
}
7889
]
7990
}
@@ -101,6 +112,13 @@
101112
"image": "https://pbs.twimg.com/profile_images/888727786797412352/DEZ1mRjs_400x400.jpg",
102113
"bio": "Solutions Architect Architect at AWS",
103114
"linkedin": "ananthanr"
115+
},
116+
{
117+
"headline": "Python Example Presented by Umang Aggarwal",
118+
"name": "Umang Aggarwal",
119+
"image": "https://media.licdn.com/dms/image/D5603AQGPJSLqUSGPmA/profile-displayphoto-shrink_800_800/0/1684261011000?e=1707350400&v=beta&t=YoDvcLUA8y_w5ZAq0p6wDNL5nut8PVKCUvrf6rTi43A",
120+
"bio": "Cloud Support Engineer at AWS",
121+
"linkedin": "umangaggarwal"
104122
}
105123
]
106-
}
124+
}

0 commit comments

Comments
 (0)