# ManagedKafkaEventSource

Use a MSK cluster as a streaming source for AWS Lambda.

Extends: StreamEventSource › ManagedKafkaEventSource
Implements: IEventSource

- Source: [`aws-lambda-event-sources/lib/kafka.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-lambda-event-sources/lib/kafka.ts#L231)
- Type last changed: v2.77.0 · 26 Apr 2023

## Example

```ts
import { ManagedKafkaEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';
import { StartingPosition, Function } from 'aws-cdk-lib/aws-lambda';

// With provisioned pollers and poller group for cost optimization
declare const myFunction: Function;
myFunction.addEventSource(new ManagedKafkaEventSource({
  clusterArn: 'arn:aws:kafka:us-east-1:123456789012:cluster/my-cluster/abcd1234-abcd-cafe-abab-9876543210ab-4',
  topic: 'orders-topic',
  startingPosition: StartingPosition.LATEST,
  provisionedPollerConfig: {
    minimumPollers: 2,
    maximumPollers: 10,
    pollerGroupName: 'shared-kafka-pollers',
  },
}));
```

## Initializer

```ts
new ManagedKafkaEventSource(props: ManagedKafkaEventSourceProps)
```

## Properties

- `eventSourceMappingArn`: string — The ARN for this EventSourceMapping.

- `eventSourceMappingId`: string — The identifier for this EventSourceMapping.

## Methods

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