S3EventSource(bucket, *, events, filters=None)¶
Use S3 bucket notifications as an event source for AWS Lambda.
import aws_cdk.aws_lambda_event_sources as eventsources import aws_cdk.aws_s3 as s3 # fn: lambda.Function bucket = s3.Bucket(self, "Bucket") fn.add_event_source(eventsources.S3EventSource(bucket, events=[s3.EventType.OBJECT_CREATED, s3.EventType.OBJECT_REMOVED], filters=[s3.NotificationKeyFilter(prefix="subdir/")] ))
EventType]) – The s3 event types that will trigger the notification.
NotificationKeyFilter]]) – S3 object key filter rules to determine which objects trigger this event. Each filter must include a
suffixthat will be matched against the s3 object key. Refer to the S3 Developer Guide for details about allowed filter rules.
lambda.addEventSourceto allow the event source to bind to this function.
- Return type