:wave: I might be misunderstanding something but ...
# help
b
๐Ÿ‘‹ I might be misunderstanding something but it seems like the event bridge
addRules
function has lost some functionality. here we prevent setting up the
targets
https://github.com/serverless-stack/serverless-stack/blob/eed6864ee360edeac18312182bcd923ae9e87410/packages/resources/src/EventBus.ts#L19 but it means we cannot set the
RuleTargetInput
this is the CF reference for it https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutTargets.html I'm basically trying to set
InputTransformer
and
InputPath
, any pointers? or should I revert to CF for this?
t
@Frank is most familiar with this construct so will let him respond
f
taking a look..
c
Not certain if itโ€™s the ideal way to add these props, but I think this format worked -
Copy code
new events.Rule(this, 'Event Lake Rule', {
      ruleName: 'event-lake-rule',
      enabled: true,
      eventBus: events.EventBus.fromEventBusName(this, 'SubSystem EventBus', subsystemEventBusName),
      eventPattern: { source: ['custom'] },
      targets: [
        new targets.KinesisFirehoseStream(deliveryStream, {
          message: events.RuleTargetInput.fromObject({
            id: 'EventLake',
            arn: deliveryStream.attrArn,
            roleArn: eventBridgeRole.roleArn,
            // Add EOL delimiter to aid parsing in CLI utility
            inputTransformer: {
              inputTemplate: '<aws.events.event>\n',
            },
          }),
        }),
      ],
    });
t
Yeah you can do it using normal CDK as a fallback, btw you don't have to import the bus, if you have a handle to
sst.EventBus
it has a field on it to get the underlying eventbus
f
@Boris Tane, what target is this? Lambda function?
b
trying the above, thanks @Clayton
@Frank I'm sending to a sqs queue
f
Expanding on @Claytonโ€™s answer:
Copy code
const myQueue = new Queue(this, "MyQueue");

new EventBus(this, "Bus", {
  rules: {
    rule1: {
      eventPattern: { source: ["myevent"] },
      targets: [
        {
          queue: myQueue,
          targetProps: {
            message: events.RuleTargetInput.fromObject({
              id: 'EventLake',
              arn: deliveryStream.attrArn,
              roleArn: eventBridgeRole.roleArn,
              // Add EOL delimiter to aid parsing in CLI utility
              inputTransformer: {
                inputTemplate: '<aws.events.event>\n',
              },
            }),
          },
        },
      ],
    },
  },
});
s
Ohh nicee. I've been just using the CDK construct but SST one looks cleaner and shorter, will probably switch to it. BTW here how to map dynamic path from eventbridge's props for example here, the
detail
:
Copy code
message: events.RuleTargetInput.fromEventPath('$.detail'),
b
works all good, thanks all ๐Ÿ‘