# DynamoEventSource

Use an Amazon DynamoDB stream as an event source for AWS Lambda.

Extends: StreamEventSource › DynamoEventSource
Implements: IEventSource

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

## Example

```ts
import * as eventsources from 'aws-cdk-lib/aws-lambda-event-sources';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';

declare const fn: lambda.Function;
const table = new dynamodb.Table(this, 'Table', {
  partitionKey: {
    name: 'id',
    type: dynamodb.AttributeType.STRING,
  },
  stream: dynamodb.StreamViewType.NEW_IMAGE,
});

fn.addEventSource(new eventsources.DynamoEventSource(table, {
  startingPosition: lambda.StartingPosition.LATEST,
  metricsConfig: {
    metrics: [lambda.MetricType.EVENT_COUNT],
  }
}));
```

## Initializer

```ts
new DynamoEventSource(table: ITable, props: DynamoEventSourceProps)
```

## 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.
