S3EventSourceProps

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

Bases: object

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

  • filters (Optional[Sequence[NotificationKeyFilter]]) – 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.

Example:

import aws_cdk.aws_lambda_event_sources as eventsources
import aws_cdk.aws_s3 as s3

# fn is of type 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/")]
))

Attributes

events

The s3 event types that will trigger the notification.

Return type

List[EventType]

filters

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.

Return type

Optional[List[NotificationKeyFilter]]