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?

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
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인