2

For AWS Eventbridge, how do pass the correlation-id with the message. From the AWS SDK documentation, there is not field to set the message attribute. Does this mean we have to pass the correlation-id together with the body?

this.eventBridge
  .putEvents({
    Entries: events.map((e) => ({
      Detail: JSON.stringify({
        ...e,
        correlationId: this.correlationId,
      }),
      DetailType: Type,
      EventBusName: this.busName,
      Source: "source",
      Time: new Date(e.eventTimestamp),
    })),
  })
  .promise()

Is this the best way for us to pass the correlation-id?

2 Answers2

0

You do not have to pass via the body but you could. If you choose not to then, using something like the equivilent of aws powertools for Python . Perhaps this might help https://www.npmjs.com/package/@dazn/lambda-powertools-correlation-ids

dorriz
  • 1,927
  • 3
  • 12
  • 19
0

Also if you want to pass this kind of data through the eventBridge event you could use the approach of ataching metadata in the details object

detail: {

metadata: { // if the event needs enriching then forward it to the enricher correlation_id: *******, }, }

as described here https://www.boyney.io/blog/2022-02-11-event-payload-patterns

dorriz
  • 1,927
  • 3
  • 12
  • 19