Overview
Bedrock Chat uses AWS CDK to define and deploy its infrastructure. The application consists of multiple stacks that work together to provide a complete chat solution with RAG capabilities.Main Stacks
BedrockChatStack
The primary application stack that deploys the complete chat infrastructure. Stack ID:BedrockChatStack
Location: cdk/lib/bedrock-chat-stack.ts
Key Components:
- Frontend: CloudFront distribution with S3 origin for React application
- Authentication: Cognito User Pool with optional identity providers (Google, OIDC)
- Backend API: HTTP API Gateway with Lambda integration
- WebSocket: WebSocket API for streaming responses
- Database: DynamoDB tables for conversations, bots, audit logs, and analytics
- Embedding: Step Functions state machine for RAG document processing
- Bot Store: OpenSearch Serverless collection for bot discovery (optional)
Environment name (max 10 chars, alphanumeric)
Prefix for resource names based on environment
AWS region where Bedrock services are available
Web ACL ID for CloudFront distribution protection
Array of identity provider configurations for SSO
Enable standby replicas for OpenSearch collections
Enable Bedrock global inference routing
Enable Bedrock cross-region inference
Enable bot store for sharing and discovering bots
Prefix for S3 bucket names (lowercase alphanumeric + hyphens)
DocumentBucketName: S3 bucket for document uploadsFrontendURL: Application frontend URLCloudFrontURL: CloudFront distribution URLConversationTableNameV3: DynamoDB conversation table nameBotTableNameV3: DynamoDB bot table nameEmbeddingStateMachineArn: Step Functions ARN for document processing
ApiPublishmentStack
Stack for publishing bot APIs as standalone REST APIs with usage plans and API keys. Stack ID: Dynamic based on published API name Location:cdk/lib/api-publishment-stack.ts
Key Components:
- REST API: API Gateway with Lambda integration
- SQS Queue: Message queue for async processing
- Lambda Handlers: Docker-based handlers for API and queue processing
- WAF Integration: Web ACL association for security
AWS region for Bedrock API calls
DynamoDB table for conversations
DynamoDB table for bot configurations
IAM role ARN for DynamoDB access with row-level security
Web ACL ARN for API Gateway protection
API Gateway usage plan configuration (throttle, quota, burst limits)
S3 bucket for storing large messages exceeding Lambda limits
ApiId: REST API IDApiName: REST API nameApiUsagePlanId: Usage plan ID for API key managementDeploymentStage: API deployment stage name
BedrockCustomBotStack
Stack for creating custom bots with dedicated Knowledge Bases and guardrails. Stack ID: Dynamic based on bot configuration Location:cdk/lib/bedrock-custom-bot-stack.ts
Key Components:
- Vector Collection: OpenSearch Serverless collection for embeddings
- Vector Index: Index configuration for semantic search
- Knowledge Base: Bedrock Knowledge Base with S3 and web crawler data sources
- Guardrails: Bedrock Guardrails for content filtering (optional)
User ID of the bot owner
Unique identifier for the bot
S3 bucket containing bot documents
Foundation model for generating embeddings
Strategy for chunking documents (fixed-size, semantic, hierarchical)
Array of URLs for web crawler data source
Guardrail configuration with thresholds for hate, violence, sexual content, etc.
KnowledgeBaseId: Bedrock Knowledge Base IDKnowledgeBaseArn: Knowledge Base ARNDataSourceN: Data source IDs (N = 0, 1, 2…)GuardrailArn: Guardrail ARN (if configured)GuardrailVersion: Guardrail version
BedrockSharedKnowledgeBasesStack
Stack for creating shared Knowledge Bases that multiple bots can reference. Stack ID: Dynamic based on configuration Location:cdk/lib/bedrock-shared-knowledge-bases-stack.ts
Key Components:
- Shared Knowledge Bases: Multiple Knowledge Bases from a single stack
- Custom Transformation: Lambda function for document preprocessing
- Temp Bucket: S3 bucket for transformation intermediate files
S3 bucket containing shared documents
Array of Knowledge Base configurations to create
Enable standby replicas for high availability
KnowledgeBaseId{hash}: Knowledge Base IDKnowledgeBaseArn{hash}: Knowledge Base ARNDataSource{hash}0: Data source ID
FrontendWafStack
Stack for creating Web ACL to protect the CloudFront distribution. Stack ID:FrontendWafStack
Location: cdk/lib/frontend-waf-stack.ts
Key Components:
- IPv4 IP Set: Allowed IPv4 address ranges
- IPv6 IP Set: Allowed IPv6 address ranges
- Web ACL: CloudFront-scoped WAF with IP-based rules
Environment prefix for resource naming
Array of allowed IPv4 CIDR ranges
Array of allowed IPv6 CIDR ranges
WebAclId: Web ACL ARN for CloudFront association
Stack Dependencies
Deployment Order
- FrontendWafStack (if
enableFrontendWafis true) - BedrockChatStack (main application)
- BedrockCustomBotStack (deployed dynamically via CodeBuild when users create bots)
- BedrockSharedKnowledgeBasesStack (deployed via CodeBuild when shared KBs are configured)
- ApiPublishmentStack (deployed via CodeBuild when users publish bot APIs)
Region Requirements
- FrontendWafStack: Must deploy to
us-east-1(CloudFront requirement) - BedrockChatStack: Deploy to any AWS region supporting required services
- Other Stacks: Deploy to the same region as BedrockChatStack