Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

API Gateway to SNS to SQS

Created with SnapAPI GatewaySNSSQS

Create an Amazon API Gateway API that integrates with Amazon SNS and Amazon SQS

This CDK application demonstrates how to set up a topic-queue-chaining pattern using Amazon SNS and Amazon SQS behind an Amazon API Gateway. This architecture helps in setting up a highly scalable API that can consume messages/events, fan them out and process them asynchronously.
This stack deploys an Amazon API Gateway REST API that publishes requests to an SNS Topic. The SNS topic fans out these requests to 2 SQS Queues. Requests in each of these queues are processed by Lambda functions. These functions log the requests to the console [CloudWatch Logs groups].

/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  *  SPDX-License-Identifier: MIT-0
 */

'use strict'

import { Handler } from "aws-lambda";

export const handler: Handler = async (event) => {
    console.log(event);
};

< Back to all patterns


GitHub icon Visit the GitHub repo for this pattern.

Download

git clone https://github.com/aws-samples/serverless-patterns/ cd serverless-patterns/apigw-sns-sqs-lambda-cdk

Deploy

cdk deploy


Testing

See the repo for detailed testing notes.

Cleanup

1. Delete the stack: npx cdk destroy.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus".
3. You see a message confirming DELETE_COMPLETE.

Hariram Ronda

Presented by Hariram Ronda

Senior Cloud Application Architect @ AWS Professional Services.

Follow on LinkedIn