I am trying to create a s3 trigger on a lambda using python cdk. I created lambda using cdk but it's working fine and other then that many other resources aswell created using cdk but on lambda it's not creating trigger my code is this:
import aws_cdk.aws_lambda_event_sources as eventsources
import aws_cdk.aws_s3 as s3
my_lambda.add_event_source(
eventsources.S3EventSource(
mybucket,
events=[s3.EventType.OBJECT_CREATED],
filters=[
s3.NotificationKeyFilter(
prefix="start",
suffix="mysufix.csv",
),
],
)
)
Try to create an instance of eventsources
as S3EventSource
is a class and addEventSource method needs IEventSource
as source param
import aws_cdk.aws_lambda_event_sources as eventsources
import aws_cdk.aws_s3 as s3
my_lambda.add_event_source(
new eventsources.S3EventSource(
mybucket,
events=[s3.EventType.OBJECT_CREATED],
filters=[
s3.NotificationKeyFilter(
prefix="start",
suffix="mysufix.csv",
),
],
)
)
Docs: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_event_sources.S3EventSource.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.