简体   繁体   English

添加路径前缀时 EventBridge 模式无效。 “事件模式无效。原因:“名称”必须是 object 或数组...”

[英]EventBridge pattern invalid when I add a path prefix. "Event pattern is not valid. Reason: "name" must be an object or an array at..."

I am trying to create and EventBridge event that triggers when objects are created in a path prefix of my bucket.我正在尝试创建 EventBridge 事件,该事件在我的存储桶的路径前缀中创建对象时触发。 When I write the event pattern without the path prefix, it works.当我编写没有路径前缀的事件模式时,它起作用了。 When I add the path prefix, I get a failure.当我添加路径前缀时,我失败了。 I am using official documentation for syntax and this other SO question seems to confirm what I'm doing but the solution doesn't work.我正在使用语法的官方文档这个其他 SO 问题似乎证实了我在做什么,但解决方案不起作用。

I am using EventBridge to create the rule > Step 2 Build event pattern > Event pattern.我正在使用 EventBridge 创建规则 > 第 2 步构建事件模式 > 事件模式。

  • Error message:错误信息:

Event pattern is not valid.事件模式无效。 Reason: "name" must be an object or an array at [Source: (String)"{"source":["aws.s3"],"detail-type":["Object Created"],"detail":{"bucket":{"name":"test-test-20230118"},"object":{"key":[{"prefix":"raw"}]}}}";原因:“名称”必须是 object 或位于 [Source: (String)"{"source":["aws.s3"],"detail-type":["Object Created"],"detail": 的数组{"bucket":{"name":"test-test-20230118"},"object":{"key":[{"prefix":"raw"}]}}}"; line: 1, column: 83]行:1,列:83]

  • Unsuccessful pattern:不成功的模式:
{
  "source": ["aws.s3"],
  "detail-type": ["Object Created"],
  "detail": {
    "bucket": {
      "name": ["test-test-20230118"]
    },
    "object": {
      "key": [{
        "prefix": "raw"
      }]
    }
  }
}
  • Successful pattern without prefix:没有前缀的成功模式:
{
  "source": ["aws.s3"],
  "detail-type": ["Object Created"],
  "detail": {
    "bucket": {
      "name": ["test-test-20230118"]
    }
  }
}

Your pattern will work if you modify the sample event to match the name and prefix your filtering on.如果您修改示例事件以匹配名称并为您的过滤添加前缀,您的模式将起作用。 Ive not seen that error so not sure whats going on but i think its related to the sample event your testing your pattern against.我没有看到那个错误,所以不确定发生了什么,但我认为它与您测试模式所针对的样本事件有关。 Start again with the sample event (I copied the sample event from event type -> AWS Events, sample events -> Object Created and pasted it into "enter my own") and update resources, bucket->name and detail->object->key so your pattern will match it.从示例事件重新开始(我从事件类型复制示例事件 -> AWS 事件,示例事件 -> Object 创建并将其粘贴到“输入我自己的”)并更新资源,bucket->name 和 detail->object- >key 这样你的模式就会匹配它。

I assume "raw" is a directory in your "test-test-20230118" bucket.我假设“raw”是“test-test-20230118”存储桶中的一个目录。 If that is the case, use a slash such as "raw/" as prefix.如果是这种情况,请使用斜杠(例如“raw/”)作为前缀。

{
  "source": ["aws.s3"],
  "detail-type": ["Object Created"],
  "detail": {
    "bucket": {
      "name": ["test-test-20230118"]
    },
    "object": {
      "key": [{
        "prefix": "raw/"
      }]
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM