# S3EventSourceV2

S3EventSourceV2 Use S3 bucket notifications as an event source for AWS Lambda.

Extends: S3EventSourceV2
Implements: IEventSource

- Source: [`aws-lambda-event-sources/lib/s3.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-lambda-event-sources/lib/s3.ts#L39)
- Type last changed: v2.127.0 · 10 Feb 2024

## Example

```ts
import * as s3 from 'aws-cdk-lib/aws-s3';
import { S3EventSourceV2 } from 'aws-cdk-lib/aws-lambda-event-sources';

const bucket = s3.Bucket.fromBucketName(this, 'Bucket', 'amzn-s3-demo-bucket');
declare const fn: lambda.Function;

fn.addEventSource(new S3EventSourceV2(bucket, {
  events: [ s3.EventType.OBJECT_CREATED, s3.EventType.OBJECT_REMOVED ],
  filters: [ { prefix: 'subdir/' } ], // optional
}));
```

## Initializer

```ts
new S3EventSourceV2(bucket: IBucket, props: S3EventSourceProps)
```

## Methods

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