Bus
Reference doc for the `sst.aws.Bus` component.
The Bus
component lets you add an Amazon EventBridge Event Bus to your app.
Create a bus
Add a subscriber
Link the bus to a resource
You can link the bus to other resources, like a function or your Next.js app.
Once linked, you can publish messages to the bus from your function code.
Constructor
Parameters
-
name
string
-
args?
BusArgs
-
opts?
ComponentResourceOptions
BusArgs
transform?
transform.bus?
Type EventBusArgs
|
(
args
:
EventBusArgs
,
opts
:
ComponentResourceOptions
,
name
:
string
)
=>
void
Transform the EventBus resource.
Properties
arn
Type Output
<
string
>
The ARN of the EventBus.
name
Type Output
<
string
>
The name of the EventBus.
nodes
nodes.bus
Type EventBus
The Amazon EventBus resource.
SDK
Use the SDK in your runtime to interact with your infrastructure.
Links
This is accessible through the Resource
object in the SDK.
-
arn
string
The ARN of the EventBus.
-
name
string
The name of the EventBus.
Methods
subscribe
Parameters
The name of the subscription.name
string
The function that’ll be notified.subscriber
Input
<
string
|
FunctionArgs
|
“arn:aws:lambda:${string}”
>
Configure the subscription.args?
BusSubscriberArgs
Returns Output
<
BusLambdaSubscriber
>
Subscribe to this EventBus.
Add a pattern to the subscription.
Customize the subscriber function.
Or pass in the ARN of an existing Lambda function.
subscribeQueue
Parameters
The name of the subscription.name
string
The ARN of the queue orqueue
Input
<
string
|
Queue
>
Queue
component that’ll be notified.
Configure the subscription.args?
BusSubscriberArgs
Returns Output
<
BusQueueSubscriber
>
Subscribe to this EventBus with an SQS Queue.
For example, let’s say you have a queue.
You can subscribe to this bus with it.
Add a filter to the subscription.
static subscribe
Parameters
The name of the subscription.name
string
The ARN of the EventBus to subscribe to.busArn
Input
<
string
>
The function that’ll be notified.subscriber
Input
<
string
|
FunctionArgs
|
“arn:aws:lambda:${string}”
>
Configure the subscription.args?
BusSubscriberArgs
Returns Output
<
BusLambdaSubscriber
>
Subscribe to an EventBus that was not created in your app.
For example, let’s say you have an existing EventBus with the following ARN.
You can subscribe to it by passing in the ARN.
Add a pattern to the subscription.
Customize the subscriber function.
static subscribeQueue
Parameters
The name of the subscription.name
string
The ARN of the EventBus to subscribe to.busArn
Input
<
string
>
The ARN of the queue orqueue
Input
<
string
|
Queue
>
Queue
component that’ll be notified.
Configure the subscription.args?
BusSubscriberArgs
Returns Output
<
BusQueueSubscriber
>
Subscribe to an existing EventBus with a previously created SQS Queue.
For example, let’s say you have an existing EventBus and SQS Queue with the following ARNs.
You can subscribe to the bus with the queue.
Add a filter to the subscription.
BusSubscriberArgs
pattern?
Type Input
<
Object
>
Filter the messages that’ll be processed by the subscriber.
If any single property in the pattern doesn’t match an attribute assigned to the message, then the pattern rejects the message.
For example, if your EventBus message contains this in a JSON format.
Then this pattern accepts the message.
pattern.detail?
Type Record
<
string
, any
>
A JSON object of “detail” values to match against. “detail” contains the actual data or information associated with the event.
pattern.detailType?
Type any
[]
A list of “detail-type” values to match against. “detail-type” typically defines the kind of event that is occurring.
pattern.source?
Type any
[]
A list of “source” values to match against. “source” indicates where the event originated.
transform?
transform.rule?
Type EventRuleArgs
|
(
args
:
EventRuleArgs
,
opts
:
ComponentResourceOptions
,
name
:
string
)
=>
void
Transform the EventBus rule resource.
transform.target?
Type EventTargetArgs
|
(
args
:
EventTargetArgs
,
opts
:
ComponentResourceOptions
,
name
:
string
)
=>
void
Transform the EventBus target resource.