Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 5.85 KB

kafka-using-cluster.md

File metadata and controls

52 lines (35 loc) · 5.85 KB

Using an Apache Kafka cluster as an event source for Lambda

You can host an Apache Kafka cluster on AWS, or on any other cloud provider of your choice. Lambda supports Kafka as an event source regardless of where it is hosted, as long as Lambda can access the cluster.

This page describes how to use your Kafka cluster as an event source for your Lambda function.

Prerequisites

How it works

When you add your Apache Kafka cluster as a trigger for your Lambda function, the cluster is used as an event source. When you add your Kafka cluster and topic as an event source, Lambda creates a consumer group with an event source UUID.

For Amazon MSK and Self-managed Apache Kafka, the maximum amount of time that Lambda allows a function to run before stopping it is 14 minutes.

Event source API operations

When you add your Kafka cluster as an event source for your Lambda function using the Lambda console, an AWS SDK, or the AWS Command Line Interface (AWS CLI), Lambda uses APIs to process your request.

To manage an event source with the AWS CLI or AWS SDK, you can use the following API operations:

Event source mapping errors

When you add your Apache Kafka cluster as an event source for your Lambda function, if your function encounters an error, your Kafka consumer stops processing records. Consumers of a topic partition are those that subscribe to, read, and process your records. Your other Kafka consumers can continue processing records, provided they don't encounter the same error.

To determine the cause of a stopped consumer, check the StateTransitionReason field in the response of EventSourceMapping. The following list describes the event source errors that you can receive:

ESM_CONFIG_NOT_VALID
The event source mapping configuration is not valid.

EVENT_SOURCE_AUTHN_ERROR
Lambda couldn't authenticate the event source.

EVENT_SOURCE_AUTHZ_ERROR
Lambda doesn't have the required permissions to access the event source.

FUNCTION_CONFIG_NOT_VALID
The Lambda function configuration is not valid.

Note
If your Lambda event records exceed the allowed size limit of 6 MB, they can go unprocessed.