Each Serverlesspresso event is emitted to a custom event bus named “Serverlesspresso”.
An event is a change in state, or an update, like an order being placed on the customer website. Events can either carry the state (the item ordered, its modifiers, and user id) or events can be identifiers (a notification that an order was completed).
Event-driven architectures have three key components: event producers, event routers, and event consumers. A producer publishes an event to the router, which filters and pushes the events to consumers. Producer services and consumer services are decoupled, which allows them to be scaled, updated, and deployed independently.
Events are ephemeral in nature, meaning that they are not stored when received. It’s often useful to log events and their state for later inspection and playback.
Create a rule that logs every event through the application’s custom bus to CloudWatch Logs.
Go to the EventBridge console. From the AWS Management Console, select Services then select EventBridge Application Integration. Make sure your region is correct.
Choose Rules. Choose Create rule.
Serverlesspresso
.{
"source": ["awsserverlessda.serverlesspresso"]
}
In Step 4 of the wizard, choose Next.
In Step 5 of the wizard, check that the Define rule detail panel that the Event bus is Serverlesspresso
. Choose Create rule.
In this section, you will test that the rule logs all Serverlesspresso events to the correct log group. You use the Step Function workflow from module 1 to generate the events.
From the AWS Step Functions console, select the OrderProcessorWorkflow you created earlier.
From the section at top of the page showing the workflow, choose Start execution.
{
"detail": {
"orderId": "2",
"userId": "testuser2"
}
}
serverlesspresso
).awsserverlessda.serverlesspresso
).DetailType
(OrderProcessor.WorkflowStarted
).Since this event is emitted to the Serverlesspresso
event bus and contains the source awsserverlessda.serverlesspresso
, it is routed to CloudWatch Logs by the rule you created.
Go to the CloudWatch console. From the AWS Management Console, select Services then select CloudWatch in Management & Governance. Make sure your region is correct.
From the left menu, choose Log groups. Choose the log group called /aws/events/serverlesspressoEventBus
.
Each event is logged to a separate log stream. Choose the first log stream.
From the Target(s) section, choose the target named severlesspressoEventBus, then choose the first row in the Log Stream section. Expand the arrow next to the timestamp.
This shows all event information, including the TaskToken
generated by Step Functions, the event detail-type
, and the event source
.
From now on, any event that is emitted to the Serverlesspresso
custom event bus will be sent to CloudWatch Logs and available for inspection.
Next, you’ll create a rule that routes events from the Validator service to the order workflow.