🇰🇷 한국어 보기
A serverless RAG (Retrieval-Augmented Generation) chatbot system based on AWS using Amazon Bedrock Knowledge Base
This project provides an AI chatbot that operates based on internal documents (regulations, manuals, knowledge base, etc.) of companies/organizations on a secure, scalable, and cost-effective serverless platform. Designed around AWS fully managed services, it minimizes infrastructure management burden and allows focus on business logic development.
- Serverless Architecture: Fully managed infrastructure using AWS Lambda, API Gateway, and Bedrock
- RAG-based: Intelligent document search and answer generation through Amazon Bedrock Knowledge Base
- IaC-based: Infrastructure code management through Terraform
- Enhanced Security (Optional): PII protection and harmful content filtering through Bedrock Guardrails
- API Gateway: Single entry point of the system, provides RESTful API
- Lambda: Handles user requests and communicates with Bedrock
- Bedrock Knowledge Base: RAG pipeline automation and orchestration
- S3: Document storage and vector storage
- Bedrock Guardrails (Optional): PII protection and content filtering
- AWS CLI installed and configured
- Terraform installed (>= 1.0)
- Python 3.9+
- Appropriate AWS permissions (Bedrock, Lambda, API Gateway, S3, etc.)
git clone https://github.com/squatboy/amazon-bedrock-serverless-rag-bot.git
cd amazon-bedrock-serverless-rag-bot# Initialize Terraform
terraform init
# Check deployment plan
terraform plan
# Deploy infrastructure
terraform applyImportant: Bedrock Knowledge Base must be created manually in AWS Console.
- Create Knowledge Base in AWS Bedrock Console
- Use "Quick Create" option
- Connect S3 bucket data source (use bucket created by Terraform)
- Set the created Knowledge Base ID in Lambda environment variables
# Upload documents to S3 bucket
aws s3 cp your-documents/ s3://your-bucket-name/docs/ --recursive
# Execute "Sync" in Bedrock ConsoleAfter deployment completion, you can request answers from the chatbot through the API Gateway URL:
# Request example
curl -X POST https://your-api-gateway-url/chat \
-H "Content-Type: application/json" \
-d '{"message": "Please tell me about the company vacation policy"}'{
"response": "The company's annual leave is granted 15 days after 1 year from the date of employment...",
"citations": [
{
"content": "Annual leave related regulations...",
"source": "company-policy.pdf"
}
]
}