AWS Lambda Destinations

When a function is invoked asynchronously, Lambda sends the event to an internal queue. A separate process reads events from the queue and executes your Lambda function.

A common event-driven architectural pattern is to use a queue or message bus for communication. This helps with resilience and scalability. Lambda asynchronous invocations can put an event or message on Amazon Simple Notification Service (SNS), Amazon Simple Queue Service (SQS), or Amazon EventBridge for further processing.

With Destinations, you can route asynchronous function results as an execution record to a destination resource without writing additional code. An execution record contains details about the request and response in JSON format including version, timestamp, request context, request payload, response context, and response payload. For each execution status such as Success or Failure you can choose one of four destinations: another Lambda function, SNS, SQS, or EventBridge.

In this module we will build on our existing implementations, and build an Inventory service that will implement Lambda Destinations.

Inventory Architecture

First, you will create a Lambda Destination to an Inventory Event Bridge event bus on successful asynchronous invocation of the function.

Step 1: Configure the Inventory event bus as a successful Destination on OrdersFunction Lambda function

  1. Open the AWS Management Console for Lambda in a new tab or window, so you can keep this step-by-step guide open.

  2. Enter OrdersFunction in the Lambda function filter.

    Lambda Function List

  3. Select the Lambda function from the list of functions.

    Lambda Function Select

  4. In the Lambda function Designer, choose Add destination.

    Lambda Function Add Destination

  5. In the Add destination dialog box:

    • For Condition, select On success.
    • For Destination type, select EventBridge event bus.
    • For Destination, select Inventory.

    Lambda Function Add Destination

    The Lambda function must have permissions through its IAM Execution Policy to access the success and failure Destinations.
    For simplicity, the function’s IAM Execution Policy has been configured with access to EventBridge and SQS (see below).

        "Version": "2012-10-17",
        "Statement": [
                "Effect": "Allow",
                "Action": [
                "Resource": "*"
                "Effect": "Allow",
                "Action": [
                "Resource": "*"
  6. Choose Save.

    Lambda Function Save Destination

    The On success Destination is displayed.

    Lambda Function On Success Destination

Step 2: Subscribe OrdersFunction Lambda function to the Inventory SNS topic

  1. Ensure you are viewing the OrdersFunction Lambda in the AWS Console. In the Lambda function Designer, select Add trigger.

    Lambda Function Add Trigger

  2. Enter SNS in the Lambda function Trigger filter and select the SNS trigger.

    Lambda Function Filter Trigger

  3. Select Inventory in the SNS topic list and the Enable trigger checkbox is selected. Choose Add.

    Lambda Function Enable Trigger

  4. Verify that the SNS trigger is displayed.

    Lambda Function Verify Trigger

Step 3: Testing the end-to-end functionality

To test the end-to-end functionality, you will publish a message to the Orders EventBridge event bus with an EU location. This will trigger the following sequence of event-driven actions:

  1. The message containing an EU location triggers the EventBridge Rule, which you created in the previous module, to route the message to the OrderProcessing StepFunctions workflow.

  2. The OrderProcessing StepFunctions workflow sends the message to the Inventory SNS topic.

  3. The Inventory SNS topic routes the message to the OrdersFunction Lambda function.

  4. On successful execution, the OrdersFunction Lambda function sends a message to the Inventory EventBridge event bus through the On success Lambda destination.

  5. The InventoryDevRule EventBridge Rule on the Inventory EventBridge event bus logs the event to the /aws/events/inventory CloudWatch Logs log group.

Let’s test it!

  1. Open the Event Generator for EventBridge in a new tab or window, so you can keep this step-by-step guide open.

  2. Make sure that the Event Generator is populated with the following (if you clicked the link above then you should see this pre-populated)

    • Event Bus selected to Orders
    • Source should be
    • In the Detail Type add Order Notification
    • JSON payload for the Detail Template should be:
      "category": "office-supplies",
      "value": 1200,
      "location": "eu-west"

    Event Generator EventBridge

  3. Click Publish.

    Event Generator EventBridge Publish

  4. Open the AWS Management Console for CloudWatch in a new tab or window, so you can keep this step-by-step guide open.

  5. Choose Log groups in the left navigation.

  6. Enter /aws/events/inventory in the Log Group Filter and choose /aws/events/inventory log group.

    CloudWatch Logs Select Log Group

  7. In the list of Log Streams, choose the Log Stream.

    CloudWatch Logs Select Log Stream

  8. Expand the Log Stream record to verify success and explore the event schema.

    CloudWatch Logs View Log Stream

CONGRATULATIONS! You have successfully used Lambda Destinations to send a message to the Inventory EventBridge event bus, following message processing through EventBridge, Step Functions, and SNS.