如何在AWS EventBridge上按对象键后缀筛选S3数据事件

4
我已在AWS事件总线上创建了一条规则,触发Sagemaker管道的执行。为此,我拥有以下事件模式:
{
  "source": ["aws.s3"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["s3.amazonaws.com"],
    "eventName": ["PutObject", "CopyObject", "CompleteMultipartUpload"],
    "requestParameters": {
      "bucketName": ["my-bucket-name"],
      "key": [{
        "prefix": "folder/inside/my/bucket/"
      }]
    }
  }
}

我已启用 CloudTrail 来记录 S3 数据事件,并且规则正在正确触发我的 Sagemaker 流水线执行。

问题在于:每次将任何对象放置/复制到我的前缀中都会触发流水线执行。因此,我希望仅在上传特定对象时触发流水线执行,但我不知道其完整名称。

例如,我可能会拥有下面这种动态生成日期的对象名称:

my-bucket-name/folder/inside/my/bucket/2021-07-28/_SUCESS

我想用类似以下方式编写事件模式:

"prefix": "folder/inside/my/bucket/{current_date}/_SUCCESS"

或者
"key": [{
  "prefix": "folder/inside/my/bucket/"
}, {
  "suffix": "_SUCCESS"
}]

我认为AWS的事件模式不支持后缀过滤。在文档中,该行为并不清晰。 我已经配置了一个S3事件通知,并使用后缀发送筛选通知到SQS队列,但现在我不知道如何处理此队列,以便调用我的EventBridge规则来触发Sagemaker Pipeline执行。

1个回答

2

我正在研究类似的功能。

不幸的是,根据AWS文档,它只支持以下模式:

比较类型 示例 规则语法
Null UserID为空 "UserID": [ null ]
Empty LastName为空 "LastName": [""]
Equals Name为"Alice" "Name": [ "Alice" ]
And Location为"New York"且Day为"Monday" "Location": [ "New York" ], "Day": ["Monday"]
Or PaymentType为"Credit"或"Debit" "PaymentType": [ "Credit", "Debit"]
Not Weather不是"Raining" "Weather": [ { "anything-but": [ "Raining" ] } ]
Numeric (equals) Price为100 "Price": [ { "numeric": [ "=", 100 ] } ]
Numeric (range) Price大于10且小于等于20 "Price": [ { "numeric": [ ">", 10, "<=", 20 ] } ]
Exists ProductName存在 "ProductName": [ { "exists": true } ]
Does not exist ProductName不存在 "ProductName": [ { "exists": false } ]
Begins with Region以"us-"开头 "Region": [ {"prefix": "us-" } ]

这个内容已经复制到 https://stackoverflow.com/questions/68882690/aws-cloudformation-lambda-and-event-rule-lambda-not-getting-triggered-with-s3。 - Potter Rafed
没错。直到现在,还无法为键对象定义后缀。 - thatayster

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接