Eventbridge Pipe: SQS > EventBus - using sqs message body as event detail

0

I have a simple AWS EventBridge pipe: SQS > EventBus

The message body of the SQS message (which is a JSON object) should be the event detail of the EventBus event. But the input template (while working in the AWS console preview) causes the pipe execution to fail. No idea why

My pipe definition in CDK which would describe what I want to achieve:

    new pipes.CfnPipe(this, "pipe", {
      roleArn: pipeRole.roleArn,
      source: queue.queueArn,
      target: eventBus.eventBusArn,
      targetParameters: {
        eventBridgeEventBusParameters: {
          detailType: "FbaNotifcation",
          source: serviceName,
        },
        inputTemplate: `<$.body>`,
      },
    });

So inputTemplate: <$.body> does not work (execution fails). Omitting inputTemplate works, but produces a different result. Using {Payload: <$.body>} does not work, but also not ideal.

Is it not possible to create a top level object from JSON path with pipes?

  • Which is the error message that it is returning?

Florian
已提問 1 年前檢視次數 318 次
1 個回答
0

Based on your code, it seems you are trying to use AWS Pipes, which is a feature that allows data to be streamed from a source to a target. However, the issue here is that the inputTemplate is expecting a valid JSONPath expression. The JSONPath expression <$.body> might not be valid in this context. JSONPath expressions usually start with $, and they use dot notation or bracket notation to traverse the JSON structure.

In the case of SQS messages, the body of the message is not a top-level field in the message attributes, so it cannot be accessed directly with a JSONPath expression. Instead, you may need to use a Lambda function to transform the SQS message into the format that EventBridge requires.

Here is an example of how you can do this:

  1. Create a Lambda function that is triggered by SQS messages.
  2. In the Lambda function, parse the SQS message to extract the body.
  3. Format the body into the detail field of the EventBridge event.
  4. Use the AWS SDK to send the event to EventBridge.
profile picture
專家
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南