S3EventSource

class aws_cdk.aws_lambda_event_sources.S3EventSource(bucket, *, events, filters=None)

Bases: object

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

ExampleMetadata:

infused

Example:

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/")]
))
Parameters:
  • bucket (Bucket) –

  • events (Sequence[EventType]) – The s3 event types that will trigger the notification.

  • filters (Optional[Sequence[Union[NotificationKeyFilter, Dict[str, Any]]]]) – S3 object key filter rules to determine which objects trigger this event. Each filter must include a prefix and/or suffix that will be matched against the s3 object key. Refer to the S3 Developer Guide for details about allowed filter rules.

Methods

bind(target)

Called by lambda.addEventSource to allow the event source to bind to this function.

Parameters:

target (IFunction) –

Return type:

None

Attributes

bucket