如何使用 AWS EventBridge 角色事件转换器

How to use AWS EventBridge Role Event Transformer

在 EventBridge 上发布的源事件为:

{
  version: '0',
  id: '1234-5678-9102-3456-7890',
  'detail-type': 'My-Detail-Type',
  source: 'My-Source',
  account: '328927794502',
  time: '2021-01-29T23:52:48Z',
  region: 'us-east-1',
  resources: [],
  detail: { year: '2020' }
}

我继续使用目标转换器创建 EventBridge 规则:

对于 Input Path 我输入:

{"data_joined":"$.detail.year"}

对于输入模板,我输入:

{"Data-Joined" : <data_joined>}

现在,当这个事件被转换并发送到目的地(它可能是 Lambda 函数、CloudWatch 事件日志组等)时,我希望转换后的事件是:

{
  version: '0',
  id: '1234-5678-9102-3456-7890',
  'detail-type': 'My-Detail-Type',
  source: 'My-Source',
  account: '328927794502',
  time: '2021-01-29T23:52:48Z',
  region: 'us-east-1',
  resources: [],
  detail: { Data-Joined: '2020' }
}

不幸的是,这不起作用,因为我无法在任何地方找到这个转换后的事件。有什么我应该做的不同吗

API_PutTargets 页面上有一条关于 CloudWatch 的注释:

Note If your are using InputTransformer with CloudWatch Logs as a target, the Template must be {"timestamp":,"message":}.

另外,我假设你已经做到了,但是有一个 Common Issues with Transforming Input