Architecture Overview
Unlike traditional applications that store API keys server-side, Workshop Cloud Chat uses a client-provided credentials model:- Users enter their AWS credentials directly in the browser UI
- Credentials are sent with each API request to
/api/chat - The server creates a temporary AWS Bedrock client for each request
- Credentials are never stored or logged
This architecture ensures that:
- Each user uses their own AWS account and quotas
- No shared credentials means no shared security risks
- Users have full control over their AWS access
Required User-Provided Credentials
Users must provide the following through the application UI:AWS Bedrock Configuration
Optional Environment Variables
While the core application doesn’t require server-side environment variables, you may want to configure these for specific use cases:Development Environment
.env.local
Production Optimizations
Security Best Practices
For Deployment
For End Users
Recommend these practices to your users:
- Use IAM Users: Create dedicated IAM users for the application, not root credentials
- Temporary Credentials: Consider AWS STS for temporary credentials with
sessionToken - Credential Rotation: Regularly rotate access keys
- Monitor Usage: Check AWS CloudTrail for unexpected API calls
API Request Flow
Here’s how credentials are used in each request:src/pages/api/chat.ts
Each request creates a new AWS SDK client with the provided credentials. The client is automatically garbage collected after the request, ensuring credentials are never persisted.
Configuration Validation
The API endpoint validates all required parameters:400 Bad Request response, prompting users to provide the required information.
Deployment Checklist
Before deploying to production:- Remove any hardcoded credentials from code
- Verify
.gitignoreincludes.env*files - Configure HTTPS (automatic with AWS Amplify)
- Test with temporary AWS credentials
- Document credential requirements for end users
- Set up CloudWatch logging for API errors
- Configure appropriate Lambda timeout in Amplify Console
Troubleshooting
”Missing AWS credentials” Error
Cause: User hasn’t provided credentials through the UI Solution: Ensure your application UI collects all required fields before making API requests”Access Denied” Error
Cause: User’s IAM credentials lack Bedrock permissions Solution: Users needbedrock:InvokeAgent permission for their agent resources
”Invalid Session Token” Error
Cause: Temporary credentials have expired Solution: Users should refresh their STS credentials and reconnectNext Steps
- Review the API Reference for complete parameter details
- Learn about AWS Amplify deployment
- Explore AWS IAM best practices