I currently have an EventBus deployed in the stack...
# sst
r
I currently have an EventBus deployed in the stack via the cdk. I use Lambdas and the SDK to spinup new events and rules for that bus dynamically. I would like to use an onDelete script that runs, when I sst remove, before the EventBus gets deleted, but positioned in the code in a way that it can receive the eventbus cdk object (along with other objects for other dynamic resources). Is this possible?
f
Hey @Ryan Weaver, does this work for you
Copy code
new Script(this, "EventBusCleanup", {
  onDelete: "src/eventBusCleanup.handler",
  params: {
    eventBusArn: myEventBus.eventBusArn,
  },
});
by referencing
myEventBus.eventBusArn
, CloudFormation makes the Script depends on the event bus.
r
@Frank will this run prior to the destruction of the myEventBus or after?
f
prior, b/c Script depends on the event bus, it will get removed first, then the event bus gets removed