AWS architecture template

AWS serverless API

API Gateway with a Cognito JWT authorizer, Lambda handlers, DynamoDB storage and an SQS queue for background jobs.

Open in editor

Free to start. Updated .

Diagram of the AWS serverless API template

When to use it

Use this template for a new API with spiky or unpredictable traffic where you would rather pay per request than run servers. Clients sign in with Amazon Cognito, API Gateway validates the JWT before any code runs, Lambda functions handle each route, and DynamoDB stores the data. Work that does not need to finish inside the request goes onto an SQS queue, and a second Lambda function picks it up, retries failures and parks poison messages on a dead-letter queue.

The trade-offs are cold starts, the 15-minute Lambda limit and DynamoDB's access-pattern-first data modelling. Design your keys around the queries you need before you write code, because changing them later means migrating data. CloudWatch collects logs and metrics from every function, so set alarms on errors, throttles and queue age from day one. If you need relational queries, swap DynamoDB for Aurora Serverless and connect to it through RDS Proxy.

What's in this template

  • User / ActorWeb or mobile client
  • CognitoUser pool issues JWTs
  • API GatewayHTTP API with JWT authorizer
  • LambdaRequest handlers
  • CloudWatchLogs, metrics and alarms
  • DynamoDBSingle-table data model
  • SQSBackground jobs, with a dead-letter queue
  • LambdaQueue worker

How it connects

  • User / Actor → Cognito (api): Sign in
  • User / Actor → API Gateway (api): HTTPS + JWT
  • API Gateway → Cognito (dependency): Validate token
  • API Gateway → Lambda (Request handlers) (api): Lambda integration
  • Lambda (Request handlers) → DynamoDB (data): Read/write items
  • Lambda (Request handlers) → SQS (data): Enqueue job
  • SQS → Lambda (Queue worker) (data): Event source mapping
  • Lambda (Queue worker) → DynamoDB (data): Update status
  • Lambda (Request handlers) → CloudWatch (dependency): Logs and metrics

More AWS templates

Make it your own

Open a copy in the editor, then rename, rearrange and extend it.