Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pattern submission - API GW to SQS to Lambda to DynamoDB #1481

Closed
ravikirang28 opened this issue Jul 6, 2023 · 0 comments
Closed

New pattern submission - API GW to SQS to Lambda to DynamoDB #1481

ravikirang28 opened this issue Jul 6, 2023 · 0 comments
Assignees

Comments

@ravikirang28
Copy link

Description

New Serverless pattern for building an API endpoint for asynchronous processing. This pattern explains how to deploy a SAM application with Amazon API Gateway, Amazon SQS, AWS Lambda, and Amazon DynamoDB.

Language

Python

Framework

SAM

Description

This pattern explains how to deploy a SAM application with Amazon API Gateway, Amazon SQS, AWS Lambda, and Amazon DynamoDB. This pattern can be used as an example for building APIs which responds to requests quickly and offloads the processing to reliable and scalable serverless components.

  • This pattern deploys an Amazon API Gateway HTTP API with route /submit configured with basic authentication.
  • On receiving a request, API Gateway will invoke a Lambda authorizer which validates the request and returns a policy informing API Gateway to accept or deny the request. Basic auth is used here for simplicity but lambda authorizer can be even used to authorize requests with any IDP of choice.
  • When request is accepted, API Gateway sends the message payload to a queue in SQS. SQS uses another queue as Dead Letter Queue to send the messages in case of continued failures to process the messages from downstream lambda.
  • Messages from SQS is posted to a lambda function to process them.
  • Lambda function receives the messages from SQS and saves them into a DynamoDB table.

Deployment commands

sam deploy --guided

GitHub PR for template:

#1480

Payload example

Example POST Request: https://{HttpApiEndpoint}.execute-api.us-east-1.amazonaws.com/submit

  • Request Header: "Content-Type: application/json"
  • Request Header: "Authorization: Basic " (where credentials is the Base64 encoding of ID and password joined by a single colon :)
  • Request Body: {"eventId":"value1", "message":"event message for testing"}

Additional Resources

Lambda Authorizers
Amazon SQS dead-letter queues
Working with HTTP APIs

Author bio

Name: Ravi Kiran Ganji
Description (up to 255 chars): I am a Senior Cloud Application Architect at AWS Professional Services, and Serverless Enthusiast.

@ravikirang28 ravikirang28 changed the title New pattern submission New pattern submission - API GW to SQS to Lambda to DynamoDB Jul 6, 2023
@jbesw jbesw closed this as completed Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants