[英]python cdk to create lambda trigger on s3 bucket
Hi I want to create a trigger on lambda function when a new json file is uploaded on s3 bucket.您好我想在 s3 存储桶上上传新的 json 文件时在 lambda 函数上创建触发器。 rule for trigger are
触发规则是
Trigger Rules for Lambda invocation using s3使用 s3 触发 Lambda 调用规则
**folder name** on which it will trigger is : input-files
**file name** ending with _processed.json OR 000.json
I am trying this but not working and not sure about multiple rules for file ending我正在尝试这个但不工作并且不确定文件结束的多个规则
trigger-_lambda.add_event_source(_aws_lambda_event_sources.S3EventSource(
bucket,
events=[
_s3.EventType.OBJECT_CREATED],
filters=[
_s3.NotificationKeyFilter(
prefix="input",
suffix="_processed.json" , "000.json ")]
))
is this the way to do this properly ?这是正确执行此操作的方法吗? any help would be appreciated
任何帮助,将不胜感激
S3 doesn't allow you to define multiple suffix rules in a filter. S3 不允许您在过滤器中定义多个后缀规则。
To work around this, you would need to define two separate event sources:要解决此问题,您需要定义两个单独的事件源:
my_lambda.add_event_source(
lambda_event_sources.S3EventSource(
bucket,
events=[s3.EventType.OBJECT_CREATED],
filters=[
s3.NotificationKeyFilter(
prefix="input",
suffix="_processed.json",
),
],
)
)
my_lambda.add_event_source(
lambda_event_sources.S3EventSource(
bucket,
events=[s3.EventType.OBJECT_CREATED],
filters=[
s3.NotificationKeyFilter(
prefix="input",
suffix="000.json",
),
],
)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.