Skip to content

Added Python Handler file for Lambda Kinesis Integration #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions integration-kinesis-to-lambda/main.py
Original file line number Diff line number Diff line change
@@ -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.")
22 changes: 20 additions & 2 deletions integration-kinesis-to-lambda/snippet-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
]
}
]
}
Expand Down Expand Up @@ -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"
}
]
}
}