# SelfManagedKafkaEventSource

Use a self hosted Kafka installation as a streaming source for AWS Lambda.

Extends: StreamEventSource › SelfManagedKafkaEventSource
Implements: IEventSource

- Source: [`aws-lambda-event-sources/lib/kafka.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-lambda-event-sources/lib/kafka.ts#L358)

## Example

```ts
import { SelfManagedKafkaEventSource, AuthenticationMethod } from 'aws-cdk-lib/aws-lambda-event-sources';
import { StartingPosition, Function } from 'aws-cdk-lib/aws-lambda';
import { ISecret } from 'aws-cdk-lib/aws-secretsmanager';

// With provisioned pollers and poller group for cost optimization
declare const myFunction: Function;
declare const kafkaCredentials: ISecret;
myFunction.addEventSource(new SelfManagedKafkaEventSource({
  bootstrapServers: ['kafka-broker1.example.com:9092', 'kafka-broker2.example.com:9092'],
  topic: 'events-topic',
  secret: kafkaCredentials,
  startingPosition: StartingPosition.LATEST,
  authenticationMethod: AuthenticationMethod.SASL_SCRAM_512_AUTH,
  provisionedPollerConfig: {
    minimumPollers: 1,
    maximumPollers: 8,
    pollerGroupName: 'self-managed-kafka-group', // Group pollers to reduce costs
  },
}));
```

## Initializer

```ts
new SelfManagedKafkaEventSource(props: SelfManagedKafkaEventSourceProps)
```

## Methods

- `bind(target: IFunction): void` — Called by `lambda.addEventSource` to allow the event source to bind to this function.
