Diagram 5 of 12

Serverless site with login and API

A site with authentication and a serverless API. Amplify Hosting serves the front end, Cognito issues JWT tokens, API Gateway validates each token, and Lambda applies the logic on top of DynamoDB.

AWS Amplify HostingAmazon CognitoAmazon API GatewayAWS LambdaAmazon DynamoDB

Diagram

Diagram 5: serverless site with login and API (Amplify, Cognito, API Gateway, Lambda, DynamoDB)AWS CloudUsersAMPAWS AmplifyHosting (HTML/JS)COGAmazon Cognito(login and tokens)APIAmazon APIGatewayλAWS Lambda(logic)DDBAmazon DynamoDB(data)123451. The user loads the HTML and JavaScript site from AWS Amplify Hosting.2. The user signs in with Amazon Cognito and receives a JWT token.3. The browser's JavaScript calls Amazon API Gateway with the token.4. API Gateway validates the token and invokes the Lambda function.5. Lambda reads or writes DynamoDB and returns the response.

Comments

Information flow

  1. AWS Amplify Hosting

    The user loads the HTML and JavaScript site from Amplify Hosting.

  2. Amazon Cognito

    The user signs in with Cognito and receives a JWT token.

  3. Amazon API Gateway

    The browser's JavaScript calls API Gateway, sending the token.

  4. Amazon API Gateway

    API Gateway validates the token and, if it is valid, invokes the matching Lambda function.

  5. AWS Lambda + Amazon DynamoDB

    Lambda reads or writes DynamoDB, builds the response and returns it through API Gateway.