当文件上传到任何目录时,我希望事件桥规则能够匹配同一 S3 存储桶的两个不同目录(前缀)。
如果我将两个前缀对象放在detail.object.key下,则规则仅匹配最后一个对象,按照下面的事件模式:
{
"source": ["aws.s3"],
"detail-type": ["Object Created"],
"detail": {
"bucket": { "name": ["some-bucket"] },
"object": {
"key": [
{ "prefix": "some-prefix/" },
{ "prefix": "some-other-prefix/" }
]
}
}
}
文档不清楚如何实现这一点。
我找到了一种使用基于内容的过滤和 $or 匹配来做到这一点的方法。
文档仍然不清楚具体的用例,但经过几次试验和错误后,我通过声明事件模式来使其工作,如下所示:
{
"source": ["aws.s3"],
"detail-type": ["Object Created"],
"detail": {
"bucket": {
"name": ["some-bucket"]
},
"$or": [
{
"object": {
"key": [{
"prefix": "some-prefix/"
}]
}
},
{
"object": {
"key": [{
"prefix": "some-other-prefix/"
}]
}
}
]
}
}
希望有帮助!