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

Conversation

Umang-Aggarwal-07
Copy link
Contributor

@Umang-Aggarwal-07 Umang-Aggarwal-07 commented Dec 6, 2023

*Issue #, if available: #101

*Description of changes: Added Python Handler file for Lambda Kinesis Integration

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

import json
import boto3
def lambda_handler(event, context):
kinesis = boto3.client('kinesis')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinesis client initialised but not used. Remove.

print(f"An error occurred {e}")
raise e
print(f"Successfully processed {len(event['Records'])} records.")
def get_record_data(payload):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need a separate function for just decoding. This can be pulled into handler logic.

print(f"Successfully processed {len(event['Records'])} records.")
def get_record_data(payload):
data = base64.b64decode(payload['data']).decode('utf-8')
# Placeholder for actual async work, you can use asyncio or threading for that
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see need to recommend asyncio or threading. Remove comment.

@@ -0,0 +1,19 @@
import base64
import json
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import not used. Remove.

@@ -0,0 +1,19 @@
import base64
import json
import boto3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove import. See comment for kinesis client below.

@Umang-Aggarwal-07
Copy link
Contributor Author

Updated main.py as per the review suggestion.

Copy link

@arthi-j arthi-j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested code, looks good.

@boyney123
Copy link
Contributor

Thanks for the review, will merge this in now.

@boyney123 boyney123 merged commit 1d488e6 into aws-samples:main Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants