AWS Lambda to Amazon EventBridge to Amazon SNS

AWS Lambda → EventBridge → SNS

Route events from EventBridge to multiple SNS topics.

The AWS SAM template deploys three EventBridge Buses, six EventBridge Rules (2 per bus), four SNS Topics, three SQS queues and a Lambda function. The lambda function is an event generator which sends events to EventBridge Buses that trigger appropriate Rules sending the payload to the appropriate SNS Topic. SQS queues are attached to the Rules as Dead Letter Queues. Appropriate permissions are granted to EventBridge to trigger the SNS Topics and the Lambda function to put events in the EventBridge.
Consider this example: countries report cross-border transactions to their respective central banks. For simplicity, transactions originate from bank branches or ATM (automatic teller machines) as sub-domains (source) from all banks. For simplicity we use three EventBridge Buses - (bluebank, redbank and greenbank). The 'DetailType' is filtering for 'transaction type' and the 'Detail' section filters the 'Yes/No' reportable field. Based on these combinations, events trigger different rules and send transaction payloads to SNS Topics of the ReserveBank and/or the Transaction Warehouses of the respective bank's SNS topics.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-eventbridge-sns-sam

Deploy

sam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

1. Delete the stack: sam delete --stack-name STACK_NAME.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"

Created by:

Sylvester Kachi

Sylvester is a Solutions Architect at AWS

Follow on LinkedIn