Getting Startedbasic5 minute guide

Secure Application Authentication with Amazon Cognito

This architecture separates identity verification from application authorization. Cognito authenticates the user, API Gateway validates the presented token, Lambda enforces business rules, and DynamoDB remains behind the application boundary.

Open editable diagram

Published August 18, 2026

Reference architecture

Architecture diagram

Edit this exact diagram
Secure AWS authentication architecture diagram with Amazon Cognito, API Gateway authorizer, Lambda, and DynamoDBOpen on the canvas

Secure AWS authentication architecture diagram with Amazon Cognito, API Gateway authorizer, Lambda, and DynamoDB. The image links to a fully editable BuildPlane starter.

Overview

A straightforward authenticated application path. Cognito owns user identity, API Gateway rejects requests without a valid token, Lambda performs authorized work, and DynamoDB remains reachable only through the application function.

Components

  • Amazon Cognito: Registers users, handles sign-in, and issues short-lived tokens containing identity claims.
  • Protected API: Uses a Cognito authorizer to validate tokens before a request enters the application.
  • Application Function: Applies business authorization and performs operations for the authenticated user.
  • Private Application Data: Stores records behind the application boundary rather than exposing direct client access.

Authentication Flow

  1. The user signs in with Cognito and receives an identity token.
  2. The client presents that token to the protected API route.
  3. API Gateway validates the token before invoking the Lambda function.
  4. Lambda applies application-level authorization and reads the user’s DynamoDB records.

Customize First

  • Define user groups and claims around real application roles.
  • Add MFA and account-recovery rules that match the application risk level.
  • Use least-privilege IAM permissions for the function’s DynamoDB access.

Design rationale

Decisions that shape this architecture

1

Authenticate at the managed identity boundary

Cognito handles sign-in, recovery, token issuance, and optional federation. The application does not store or verify raw passwords itself.

2

Reject invalid tokens before invoking business logic

An API Gateway authorizer validates the token at ingress. Lambda still owns authorization decisions that depend on the requested resource or business role.

3

Keep data access behind the application

Clients do not connect directly to DynamoDB. The Lambda execution role receives only the table actions and key scope required by the API.

Before production

Operational checks

Define token lifetimes and refresh behavior for the actual client risk model.

Require MFA where account impact justifies the added friction.

Validate issuer, audience, expiry, and required claims on every protected route.

Log authorization failures without recording tokens or sensitive claims.

Scope and tradeoffs

What this diagram does not solve

Authentication does not decide every authorization rule

A valid token proves identity and carries claims. The application must still verify tenant, ownership, role, and operation-specific permissions.

Account lifecycle needs product decisions

Registration, verification, recovery, deletion, federation, and support workflows need deliberate policies beyond the request path shown here.

Common questions

Frequently asked questions

What does Cognito provide in this architecture?

Cognito manages user identity and issues tokens. API Gateway validates those tokens before invoking the application function.

Should Lambda trust every claim in a valid token?

Lambda can trust properly validated claims from the configured issuer, but it must still apply application authorization for the requested data and action.

Can Cognito federate external identity providers?

Yes. Cognito user pools can support social and enterprise federation, but provider setup and claim mapping should be designed and tested explicitly.

Keep exploring

View all 17 guides
Serverless REST API AWS architecture diagram with API Gateway, AWS Lambda, DynamoDB, and CloudWatch
Getting Startedbasic

Serverless REST API Architecture on AWS

This architecture is the smallest useful serverless API baseline: a managed HTTPS entry point, stateless function compute, on-demand data storage, and observable execution. It is intentionally compact so the first production decisions remain easy to see.

Explore the architecture

From reference to working draft

Adapt this architecture with your AWS AI Agent

Start from the exact diagram in this guide. Change requirements, challenge a decision, or ask what fails first, while keeping the architecture editable.

Open editable diagram