Amazon API Gateway with Amazon Cognito to AWS Lambda to Amazon Bedrock

Amazon Cognito → Amazon API Gateway → AWS Lambda → Amazon Bedrock

Create an AWS CDK Python application for Bedrock API with Cognito user management, domain restriction, API request throttling, and quota limits.

This sample project demonstrates how to create an API Gateway with AWS CDK, backed by a Cognito user pool for user management.
Users can register and log in via an endpoint. Registration can be restricted to a specific domain, such as '@example.com'. The application supports request throttling and quota limits to the API.
Configuration for domain restriction, request throttling, and quota management can be done using CDK context variables.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-bedrock-cognito-cdk

Deploy

Deploy the stack: <code>cdk deploy</code>Deploy the stack with context variables: <code>cdk deploy --context ORGANIZATION_DOMAIN=@example.com --context API_THROTTLE_RATE_LIMIT=1 --context API_THROTTLE_BURST_LIMIT=2 --context API_QUOTA_LIMIT=25 --contect API_QUOTA_LIMIT=DAY</code>


Testing

Run end-to-end tests: pytest

Cleanup

Delete the stack: cdk destroy.

Created by:

Inthuson Anandakumar

Inthuson Anandakumar

Inthuson Anandakumar Technical Account Manager at AWS based out of London. Inthu currently works with strategic financial services customers for AWS, helping them architect, build, and optimise cloud applications. With a background in software development and solution architecture, he thrives on crafting innovative solutions and enjoys sharing his discoveries with customers across a wide array of sectors.

Follow on LinkedIn