New Order


Until now, you have manually started the OrderProcessor workflow from the Step Functions console.

In production, the workflow is started by an event generated from the Validator service. The event is emitted each time a QR code is scanned by a customer.

  • You will create a new rule in Amazon EventBridge that passes the Validator event to your OrderProcessor workflow.
  • You will test the new rule by mocking the event sent from the Validator service.

Execution results

Creating the “New Order” rule

In this section, you will build the rule that listens to the Validator.NewOrder event and passes this to the order workflow target.

Step-by-step instructions

  1. Go to the EventBridge console. From the AWS Management Console, select Services then select EventBridge Application Integration. Make sure your region is correct.

  2. Choose Rules. Choose Create rule.

  3. In Step 1 of the wizard:

  • For the Name, enter NewOrder.
  • For Event bus, enter Serverlesspresso.
  • Choose Next.

Create rule and add name

  1. In Step 2 of the wizard:
  • For Event source, select Other.
  • Ignore the Sample event panel.
  • In the Event pattern panel, paste the following:
  • Choose Next
  "detail-type": ["Validator.NewOrder"],
  "source": ["awsserverlessda.serverlesspresso"]
  1. In Step 3 of the wizard:
  • In the Target 1 panel, choose AWS service.
  • In the Select a target dropdown, choose Step Functions state machine
  • In the State machine dropdown, choose OrderProcessorWorkflow. Tip: You can start typing OrderProcessor into the search box to find the workflow.
  • For Execution role, ensure Create a new role for the specific resource is selected.
  • Choose Next.

Select targets panel

  1. In Step 4 of the wizard, choose Next.

  2. In Step 5 of the wizard, check that the Define rule detail panel that the Event bus is Serverlesspresso. Choose Create rule.

Testing the “New Order” rule

In this section, you will test the rule that starts the OrderProcessor workflow when the NewOrder event is emitted.

Step-by-step instructions

From the AWS EventBridge Console, under Events:

  1. Choose Event buses.
  2. Choose the Serverlesspresso event bus

Select event bus

  1. Choose Send events Select send events

  2. Check that the serverlesspresso event bus is selected

  3. Copy the following into the Event source input:

  1. Copy the following into the Detail type input:
  1. Copy the following into the Event detail input:
  1. Choose Send

Select send events

This should create an event ID with a confirmation summary:

Select send events

This starts a new execution in the OrderProcessor workflow.

  1. From the AWS Step Functions console, select the OrderProcessorWorkflow you created earlier. You will see the most recent execution with the Status, Running.

Execution results

  1. Choose the latest execution from the Name column. The console shows the Execution status of Running. The left side shows the flow of execution with the green states showing the actual path. The blue state shows when execution is suspended, pending a callback.

Execution results

The new rule has successfully routed the NewOrder event to the OrderProcessor workflow. In the next step, you create a rule that routes the WorkflowStarted event to an AWS Lambda function.


  • Before this section, the Validator service published events to the custom bus when the QR code is scanned but nothing was subscribed to these events. You created a rule that subscribes to Validator events and routes the traffic to the order workflow.
  • To test, instead of scanning a QR code to trigger the Validator service, you mocked an example event and published it to the custom event bus using the CLI.
  • You verified that the Validator event triggered the rule and started the workflow.

Next steps

Next, you’ll create an event that the Order Manager microservice uses to persist details of orders.