每当在名为“mybucket”的S3存储桶中创建一个以“.csv”结尾的对象,且该对象是在“in”文件夹中创建的时,我希望通过EventBridge触发AWS Lambda函数。 目前,我拥有的EventBridge规则如下:
相比之下,使用OR逻辑关系需要额外的$or语法,就像文档中给出的这个例子一样:
那么,为什么我的规则表现出后缀和前缀条件之间似乎存在 OR 关系?我需要做哪些更改才能使它按照我想要的方式工作呢?
{
"detail-type": ["Object Created"],
"source": ["aws.s3"],
"detail": {
"bucket": {
"name": ["mybucket"]
},
"object": {
"key": [{
"suffix": ".csv"
}, {
"prefix": "in/"
}]
}
}
}
我本来希望这个规则能奏效,但实际上却没有,它的表现就像后缀和前缀条件之间有一个或关系。根据我对AWS文档(https://docs.aws.amazon.com/zh_cn/eventbridge/latest/userguide/eb-event-patterns-content-based-filtering.html#eb-filtering-complex-example)的理解,上述规则应该定义后缀和前缀过滤条件之间的与关系,类似于文档中给出的下面这个示例:
{
"time": [ { "prefix": "2017-10-02" } ],
"detail": {
"state": [ { "anything-but": "initializing" } ],
"c-count": [ { "numeric": [ ">", 0, "<=", 5 ] } ],
"d-count": [ { "numeric": [ "<", 10 ] } ],
"x-limit": [ { "anything-but": [ 100, 200, 300 ] } ]
}
}
相比之下,使用OR逻辑关系需要额外的$or语法,就像文档中给出的这个例子一样:
{
"detail": {
"$or": [
{ "c-count": [ { "numeric": [ ">", 0, "<=", 5 ] } ] },
{ "d-count": [ { "numeric": [ "<", 10 ] } ] },
{ "x-limit": [ { "numeric": [ "=", 3.018e2 ] } ] }
]
}
}
那么,为什么我的规则表现出后缀和前缀条件之间似乎存在 OR 关系?我需要做哪些更改才能使它按照我想要的方式工作呢?
in/
更改为/in/
。 - Ankush Jain[{ "suffix": ".csv" , "prefix": "in/" }]
?只需一个数组项而不是两个。 - Ankush Jain