Skip to content

MSK - Glue Schema registry demo using Python #2778

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

vaibhavjainv
Copy link
Contributor

Issue #, if available:

Description of changes:
Python implementation for MSK - Glue Schema registry demo.

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

vaibhavjainv and others added 5 commits June 28, 2025 22:43
* python implementation

* working version

* working code

* simplified code

* final changes
Copy link

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

Thats a super amazing work @vaibhavjainv! I just left some small comments.

logger.info("=== MSK AVRO Consumer Lambda started ===")

try:
record_count = 0

Choose a reason for hiding this comment

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

You can remove this.

try:
record_count = 0
for record in event.records:
record_count += 1

Choose a reason for hiding this comment

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

You can remove this.

# Add your business logic here
# For example: save to database, send notifications, etc.

logger.info(f"Successfully processed {record_count} records")

Choose a reason for hiding this comment

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

Suggested change
logger.info(f"Successfully processed {record_count} records")
logger.info(f"Successfully processed {len(list(event.records))} records")

Comment on lines 2 to 6
aws-lambda-powertools>=3.15.0

# Avro serialization
fastavro>=1.8.0
avro>=1.11.0

Choose a reason for hiding this comment

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

Suggested change
aws-lambda-powertools>=3.15.0
# Avro serialization
fastavro>=1.8.0
avro>=1.11.0
aws-lambda-powertools[kafka-consumer-avro]>=3.15.0

Comment on lines 267 to 270
logger.exception("Error in lambda_handler", extra={
"error": str(e),
"error_type": type(e).__name__
})

Choose a reason for hiding this comment

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

logger.exception already propagate error type and name.

Suggested change
logger.exception("Error in lambda_handler", extra={
"error": str(e),
"error_type": type(e).__name__
})
logger.exception("Error in lambda_handler")

response = kafka_client.get_bootstrap_brokers(ClusterArn=cluster_arn)
return response['BootstrapBrokerStringSaslIam']
except Exception as e:
logger.exception("Failed to get bootstrap brokers", extra={"cluster_arn": cluster_arn})

Choose a reason for hiding this comment

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

Suggested change
logger.exception("Failed to get bootstrap brokers", extra={"cluster_arn": cluster_arn})
logger.exception("Failed to get bootstrap brokers", cluster_arn=cluster_arn)

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.

4 participants