A comprehensive guide to building production-ready AI applications using Amazon Bedrock, featuring hands-on notebooks, agent frameworks, and deployment patterns.
building-apps-with-bedrock/
β
βββ 1 Intro_to_Bedrock_Presentation/ # Presentation slides
β βββ Module-1-GenAI-on-AWS.pdf
β βββ Module-2-Getting-to-Know-Amazon-Bedrock.pdf
β βββ Module-3-RAG-on-Bedrock.pdf
β βββ Module-4-Agents-on-Amazon-Bedrock.pdf
β βββ Module-5-LLM-Security-and-Observability-on-Bedrock.pdf
β βββ Module-6-Cost-Optimization.pdf
β
βββ 1a Basic Bedrock/ # Foundation concepts
β βββ 1-bedrock_intro.ipynb
β βββ 2-image_generation.ipynb
β βββ 3-video_generation.ipynb
β βββ 4-inference_profiles.ipynb
β
βββ 1b Async Pipeline/ # Serverless async workflows
β βββ async_pipeline_setup.ipynb
β βββ setup_infrastructure.py
β
βββ 2 RAG_in_AWS/ # Section header
β
βββ 2a Bedrock RAG/ # RAG implementations & patterns
β βββ Demo1-Basic-RAG/ # Fully managed RAG with Aurora
β βββ Demo2-S3-Vectors/ # Cost-effective S3 native vectors
β βββ Demo3-Hybrid-Search/ # Vector + keyword search fusion
β βββ Demo4-Reranking-Pipeline/ # Two-stage retrieval with re-ranking
β βββ Demo5-Multi-Collection/ # Enterprise multi-collection RAG
β βββ Demo-Chunking-Strategies/ # Document chunking optimization
β βββ Demo-RAGAS-Evaluation/ # RAG evaluation metrics
β βββ embedding_comparison_demo.ipynb # Embedding model comparison
β βββ vector_database_cost_comparison.ipynb
β
βββ 2b S3VectorsApp/ # Complete RAG application (CDK)
β βββ lambda/ # Lambda function code
β βββ s3vectors_app/ # CDK infrastructure
β βββ streamlit_app.py # Chat UI
β βββ app.py # CDK app entry point
β βββ README.md # Deployment guide
β
βββ 3 Agents_in_AWS/ # Section header
β
βββ 3a Bedrock_Agents/ # Agent development & deployment
β βββ 1-basic_agent_setup.ipynb
β βββ 2-agent_with_knowledge_base.ipynb
β βββ 3-multi_agent_collaboration.ipynb
β βββ 4-strands_with_agentcore.ipynb
β βββ 5-knowledge_base_s3_vectors.ipynb
β βββ 6-strands_agent_kb_agentcore.ipynb
β βββ 7-bedrock_guardrails.ipynb
β βββ 8-strands_guardrails_kb_agentcore.ipynb
β
βββ 3b Agentcore/ # AgentCore hands-on exercises
β βββ 1-calculator_agent.ipynb
β βββ 1a-deploy_agentcore.ipynb
β βββ 2-demo_tools.ipynb
β βββ 3-demo-agents_as_tools.ipynb
β βββ 4-demo-graph_architecture.ipynb
β βββ 5-error_handling_session_exercise.ipynb
β βββ 6-agentcore_memory_demo.ipynb
β βββ exerciseA/ # Practice exercises
β
βββ 3c Application/ # Heavy Machinery Assistant (Full Stack)
β βββ terraform/ # Infrastructure as Code
β β βββ 01_storage_stack/ # VPC, Aurora, S3
β β βββ 02_bedrock_rag_stack/ # Knowledge Base
β β βββ modules/ # Reusable modules
β βββ pre-requisites/
β β βββ documents/spec-sheets/ # Equipment specifications
β β βββ postgres_data/ # Database initialization
β βββ rag_app/ # RAG Streamlit app
β βββ agent_app/ # Agent Streamlit app
β βββ python_sdk/ # SDK-based deployment
β βββ README.md # Full deployment guide
β
βββ 3d Lambda/ # Strands Agent Lambda deployment
β βββ agent_handler.py # Lambda handler with Strands
β βββ deploy.sh # Automated deployment script
β βββ requirements.txt
β βββ README.md # Deployment guide
β
βββ Sample_UI_for/ # Interactive demo interface
β βββ app.py # Streamlit application
β βββ requirements.txt
β βββ README.md
β
βββ AGENTCORE_SUMMARY.md # AgentCore platform guide
βββ STRANDS_AGENTS_SUMMARY.md # Strands framework guide
βββ BEDROCK_KB_S3_VECTORS_SUMMARY.md # Knowledge Base + S3 Vectors guide
# Install required packages
pip install boto3 strands-agents strands-agents-tools bedrock-agentcore bedrock-agentcore-starter-toolkit
# Configure AWS credentials
aws configureLaunch the Streamlit interface to explore all capabilities:
cd Sample_UI_for
pip install -r requirements.txt
streamlit run app.pyFeatures:
- π¬ Chat with Bedrock models (Nova, Claude)
- π Knowledge Base RAG with equipment specs
- π‘οΈ Test guardrails in real-time
- π¨ Generate images with Nova Canvas
- π¬ Create videos with Nova Reel
Open http://localhost:8501 in your browser to start exploring!
Start here to understand core Bedrock capabilities:
- Bedrock Intro - Models, APIs, basic usage
- Image Generation - Nova Canvas for images
- Video Generation - Nova Reel for videos
- Inference Profiles - System vs Application profiles
Build serverless async pipelines:
- API Gateway + Step Functions + Lambda
- Image-to-video generation pipeline
- Status tracking and S3 artifact storage
Progress through agent complexity:
Basic Agents (3a Bedrock_Agents/):
- Traditional Bedrock Agents with action groups
- Knowledge Base integration
- Multi-agent collaboration patterns
Advanced Agents (3a Bedrock_Agents/):
- Strands framework with AgentCore deployment
- Knowledge Base with S3 Vectors (90% cost savings)
- Guardrails for content safety
- Production-ready secure agents
Hands-on AgentCore Exercises (3b Agentcore/):
1-calculator_agent.ipynb- Basic agent with tools1a-deploy_agentcore.ipynb- AgentCore deployment2-demo_tools.ipynb- Tool creation patterns3-demo-agents_as_tools.ipynb- Multi-agent patterns4-demo-graph_architecture.ipynb- Graph-based workflows5-error_handling_session_exercise.ipynb- Error handling6-agentcore_memory_demo.ipynb- Memory configuration
Comprehensive RAG patterns from basic to advanced:
Foundation RAG:
- Basic RAG with Bedrock Knowledge Bases
- S3 Vectors for 90% cost reduction
- Embedding model comparison and selection
Advanced Patterns:
- Hybrid search (vector + keyword fusion with OpenSearch)
- Re-ranking pipeline for improved accuracy
- Multi-collection enterprise RAG
- Document chunking strategies
- RAG evaluation with RAGAS metrics
Additional Notebooks:
vector_database_cost_comparison.ipynb- Compare vector DB costsDemo3-Hybrid-Search/opensearch_hybrid_search_guide.md- OpenSearch guideDemo4-Reranking-Pipeline/demo4_reranking_pipeline.ipynb- Reranking with BedrockDemo4-Reranking-Pipeline/demo4_s3_vectors_reranking.ipynb- Reranking with S3 Vectors
2b S3VectorsApp/ - Complete serverless RAG application:
- API Gateway with authentication
- Lambda-based vector operations
- Streamlit chat interface
- CDK infrastructure as code
- Production security practices
3d Lambda/ - Strands Agent Lambda deployment:
- Deploy Strands agents to AWS Lambda
- Public Function URL for testing
- Official Strands Lambda layers
- Automated deployment script
- Tool integration examples
3c Application/ - Heavy Machinery Assistant (Full Stack):
- Multi-AZ VPC with Aurora Serverless v2
- Bedrock Knowledge Base with pgvector
- Terraform infrastructure as code
- RAG and Agent Streamlit applications
- Equipment specification database
What: Serverless platform for deploying AI agents at scale
Why: Zero infrastructure, built-in memory, observability, security
When: Production deployments requiring scale and reliability
Key Features:
- Runtime: Serverless agent execution
- Memory: Persistent conversation history (short-term & long-term with fact extraction)
- Gateway: Transform APIs into tools
- Browser: Cloud-based automation
- Code Interpreter: Secure code execution
- Identity: Authentication & access control
- Observability: Real-time monitoring
- Policy: Security controls
- Evaluation: Continuous quality inspection
Deployment Modes:
| Mode | Command | Use Case |
|---|---|---|
| Direct Code Deploy (Default) | agentcore deploy |
Most use cases - no Docker needed |
| Local Development | agentcore deploy --local |
Rapid iteration, debugging |
| Local Build + Cloud | agentcore deploy --local-build |
Custom build needs |
Memory Options:
- Short-term memory (STM) only - available immediately
- Short-term + Long-term memory (LTM) - auto fact extraction (2-5 min to provision)
- No memory - use
--disable-memoryflag
π See AGENTCORE_SUMMARY.md for details
What: Open-source, lightweight Python SDK for building AI agents
Why: Model-driven approach, framework-agnostic, minimal code
When: Rapid agent development with any LLM provider
Key Features:
- Model-agnostic (Bedrock, OpenAI, Anthropic, Ollama, Gemini, LiteLLM, custom)
- Multi-agent patterns (Agents as Tools, Swarm, Graph, Workflow)
- Native MCP (Model Context Protocol) support
- Hot reloading for rapid development
- Bidirectional streaming for voice/audio (experimental)
- OpenTelemetry observability integration
Supported Models:
| Provider | Model IDs |
|---|---|
| Amazon Bedrock | us.amazon.nova-pro-v1:0, us.amazon.nova-lite-v1:0, etc. |
| Anthropic | claude-3-5-sonnet-20241022 |
| OpenAI | gpt-4, gpt-realtime |
gemini-2.5-flash |
|
| Ollama | llama3, any local model |
π See STRANDS_AGENTS_SUMMARY.md for details
What: Cost-effective RAG with native S3 vector storage
Why: 90% cost reduction vs traditional vector databases
When: Large-scale knowledge bases with subsecond latency tolerance
Key Features:
- Native S3 vector storage (no separate DB)
- Subsecond query performance
- Tens of millions of vectors per index
- Rich metadata filtering
- Fully managed, serverless
- SSE-S3 encryption by default
Limitations:
- Semantic search only (no hybrid search yet)
- Subsecond latency (not millisecond)
- Index immutable after creation (dimension, distance metric)
- Currently in Preview status
π See BEDROCK_KB_S3_VECTORS_SUMMARY.md for details
What: Deploy Strands agents to AWS Lambda with public Function URLs
Why: Serverless, pay-per-use, no infrastructure management
When: Simple agent deployments without persistent memory needs
Key Features:
- Official Strands Lambda layers (Python 3.10-3.13, x86_64/aarch64)
- Public Function URL for direct HTTP access
- Automated deployment via
deploy.sh - Configurable timeout (up to 900s) and memory
Layer ARN (us-east-1):
arn:aws:lambda:us-east-1:856699698935:layer:strands-agents-py3_12-x86_64:1
π See 3d Lambda/README.md for details
Goal: Production-ready agent with knowledge base and content safety
Steps:
- Run
3a Bedrock_Agents/5-knowledge_base_s3_vectors.ipynb- Create KB with equipment specs - Run
3a Bedrock_Agents/7-bedrock_guardrails.ipynb- Set up content filters - Run
3a Bedrock_Agents/8-strands_guardrails_kb_agentcore.ipynb- Deploy secure agent
Result: Agent with RAG, guardrails, deployed to AgentCore
Goal: Serverless agent deployment with public Function URL
Steps:
- Navigate to
3d Lambda/folder - Customize
agent_handler.pywith your agent logic - Run
./deploy.shto deploy - Test with curl or AWS CLI
Result: Production-ready Lambda function with Strands agent
Goal: Complete GenAI application with database, RAG, and agents
Steps:
- Navigate to
3c Application/folder - Deploy storage stack:
cd terraform/01_storage_stack && terraform apply - Initialize Aurora database with equipment data
- Upload spec sheets to S3
- Deploy Bedrock stack:
cd terraform/02_bedrock_rag_stack && terraform apply - Sync Knowledge Base
- Launch RAG app:
cd rag_app && streamlit run app.py - Launch Agent app:
cd agent_app && streamlit run app.py
Result: Full-stack application with VPC, Aurora, S3, Bedrock KB, and interactive UIs
Goal: Specialized agents working together
Steps:
- Run
3a Bedrock_Agents/3-multi_agent_collaboration.ipynb- Learn patterns - Run
3a Bedrock_Agents/4-strands_with_agentcore.ipynb- Deploy with Strands - Choose pattern: Agents as Tools, Swarm, Graph, or Workflow
Result: Coordinated multi-agent system
Goal: Complete serverless RAG app with authentication and UI
Steps:
- Navigate to
2b S3VectorsApp/folder - Follow deployment guide in README
- Deploy with CDK:
cdk deploy - Get API key and test endpoints
- Launch Streamlit UI for chat interface
Result: Production-ready RAG application with API Gateway, Lambda, and chat UI
Goal: Master comprehensive RAG implementations and optimizations
Steps:
- Foundation:
2a Bedrock RAG/Demo1-Basic-RAG/- Fully managed Bedrock KB - Cost Optimization:
2a Bedrock RAG/Demo2-S3-Vectors/- 90% cost reduction - Search Enhancement:
2a Bedrock RAG/Demo3-Hybrid-Search/- Vector + keyword fusion - Quality Improvement:
2a Bedrock RAG/Demo4-Reranking-Pipeline/- Two-stage retrieval - Enterprise Scale:
2a Bedrock RAG/Demo5-Multi-Collection/- Multi-index routing - Optimization:
2a Bedrock RAG/Demo-Chunking-Strategies/- Document processing - Evaluation:
2a Bedrock RAG/Demo-RAGAS-Evaluation/- Quality metrics - Model Selection:
2a Bedrock RAG/embedding_comparison_demo.ipynb- Embedding comparison
Result: Complete RAG expertise from basic to production-grade implementations
Goal: Serverless image-to-video pipeline
Steps:
- Run
1b Async Pipeline/async_pipeline_setup.ipynb- Provision infrastructure - Test with API Gateway endpoints
- Monitor with CloudWatch
Result: Scalable async generation pipeline
from strands import Agent, tool
@tool
def search_docs(query: str) -> str:
"""Search documentation."""
# Your implementation
return results
agent = Agent(tools=[search_docs])
response = agent("Find information about X")@tool
def search_kb(query: str) -> str:
"""Search knowledge base."""
response = bedrock_runtime.retrieve_and_generate(
input={'text': query},
retrieveAndGenerateConfiguration={
'type': 'KNOWLEDGE_BASE',
'knowledgeBaseConfiguration': {
'knowledgeBaseId': KB_ID,
'modelArn': MODEL_ARN
}
}
)
return response['output']['text']
agent = Agent(tools=[search_kb])response = bedrock_runtime.retrieve_and_generate(
input={'text': query},
retrieveAndGenerateConfiguration={
'knowledgeBaseConfiguration': {
'generationConfiguration': {
'guardrailConfiguration': {
'guardrailId': GUARDRAIL_ID,
'guardrailVersion': VERSION
}
}
}
}
)from bedrock_agentcore import BedrockAgentCoreApp
app = BedrockAgentCoreApp()
@app.entrypoint
def invoke(payload):
prompt = payload.get("prompt")
response = agent(prompt)
return {"result": str(response)}
if __name__ == "__main__":
app.run()Then deploy:
agentcore configure -e agent.py -r us-east-1
agentcore deploy
agentcore invoke '{"prompt": "Hello"}'Test in UI:
- Copy Agent ARN from deployment output
- Launch Streamlit UI:
cd Sample_UI_for && streamlit run app.py - Select "π€ Equipment Agent" or "π Secure Agent"
- Paste Agent ARN and start chatting
from strands import Agent
from strands.models import BedrockModel
SYSTEM_PROMPT = "You are a helpful assistant."
def handler(event, _context):
agent = Agent(
system_prompt=SYSTEM_PROMPT,
model=BedrockModel(model_id="us.amazon.nova-micro-v1:0", region="us-east-1")
)
prompt = event.get("prompt", "Hello!")
response = agent(prompt)
return {"response": str(response)}Deploy with:
cd "3d Lambda"
./deploy.shimport boto3
bedrock_runtime = boto3.client('bedrock-agent-runtime')
# Retrieve and generate
response = bedrock_runtime.retrieve_and_generate(
input={'text': 'What is machine learning?'},
retrieveAndGenerateConfiguration={
'type': 'KNOWLEDGE_BASE',
'knowledgeBaseConfiguration': {
'knowledgeBaseId': KB_ID,
'modelArn': 'arn:aws:bedrock:us-east-1::foundation-model/amazon.nova-pro-v1:0',
'retrievalConfiguration': {
'vectorSearchConfiguration': {
'numberOfResults': 5
}
}
}
}
)
print(response['output']['text'])| Aspect | S3 Vectors | OpenSearch Serverless | Savings |
|---|---|---|---|
| Storage | ~$0.023/GB/month | ~$0.24/OCU-hour | 90% |
| Queries | ~$0.40/million | Included in OCU | 90% |
| Upload | ~$0.40/million | Included in OCU | 90% |
| Model | Use Case | Cost | Speed |
|---|---|---|---|
| Nova Micro | Simple tasks | Lowest | Fastest (200+ tokens/sec) |
| Nova Lite | General purpose | Low | Fast |
| Nova Pro | Complex reasoning | Medium | Moderate |
| Claude Sonnet | Advanced tasks | Higher | Moderate |
| Deployment | Estimated Monthly Cost |
|---|---|
| Lambda (pay-per-use) | Near $0 for low traffic |
| AgentCore | Pay per invocation + compute |
| S3VectorsApp (CDK) | Minimal - serverless |
| Application (Terraform) | ~$50-100/month (dev) |
Application stack breakdown:
- Aurora Serverless v2: ~$0.12/hr when active (0.5-1 ACU)
- Bedrock Knowledge Base: Pay per query
- Nova Models: Pay per token (Micro < Lite < Pro)
- NAT Gateway: ~$0.045/hr + data transfer
- Use Guardrails - Content filtering, PII redaction, topic blocking
- IAM Policies - Least privilege access
- Application Profiles - Separate cost tracking and quotas
- VPC Endpoints - Private connectivity
- Encryption - KMS for sensitive data, SSE-S3 for S3 Vectors
- Monitoring - CloudWatch logs and metrics
- Secrets Manager - Store database credentials (never hardcode)
- API Key Auth - Protect API Gateway endpoints
- Rate Limiting - Usage plans to prevent overuse (e.g., 100 req/sec, 10K req/day)
- Prompt Validation - Validate inputs before sending to models
The included Streamlit UI provides an interactive way to explore all Bedrock capabilities:
cd Sample_UI_for
streamlit run app.py| Demo | Description | Requirements |
|---|---|---|
| π¬ Chat | Conversation with models | None |
| π RAG | Knowledge Base queries | Run notebook 5 in 3a Bedrock_Agents/ |
| π‘οΈ Guardrails | Content safety testing | Run notebook 7 in 3a Bedrock_Agents/ |
| π€ Equipment Agent | Agent with KB integration | Deploy notebook 6 to AgentCore |
| π Secure Agent | Agent with Guardrails + KB | Deploy notebook 8 to AgentCore |
| π¨ Images | Generate with Nova Canvas | None |
| π¬ Videos | Generate with Nova Reel | None |
- Auto-Configuration - Loads KB and guardrail configs automatically
- Chat History - Maintains conversation context
- Source Citations - Shows RAG sources and confidence
- Real-time Blocking - See guardrails in action
- Media Download - Save generated images and videos
cd Sample_UI_for
streamlit run app.py # Runs on localhost:8501python agent.py # Runs on localhost:8080agentcore configure -e agent.py
agentcore deploycd "3d Lambda"
./deploy.sh
# Returns public Function URL for testingUse notebooks in 1b Async Pipeline/ folder
cd "3c Application/terraform/01_storage_stack" && terraform apply
cd ../02_bedrock_rag_stack && terraform applycd "2b S3VectorsApp"
cdk bootstrap && cdk deployContainer-based deployment (not covered in this repo)
- Agent logs:
/aws/bedrock-agentcore/runtimes/{agent-id} - Knowledge Base logs: Configure during KB creation
- Lambda logs: Automatic
# Enable in agent configuration
agentcore configure --enable-observability- Invocation count
- Latency (p50, p99)
- Error rate
- Token usage
- Cost per request
This is a learning repository. Feel free to:
- Add new notebooks
- Improve existing examples
- Share use cases
- Report issues
- Strands Agents
- Strands SDK GitHub
- Strands Tools GitHub
- AgentCore SDK GitHub
- AgentCore Starter Toolkit
- AgentCore Samples
This project is for educational purposes. See individual component licenses:
- Strands Agents: Apache 2.0
- AWS Services: AWS Customer Agreement
By completing this repository, you will:
β
Understand Bedrock core capabilities
β
Build agents with action groups and knowledge bases
β
Implement multi-agent collaboration patterns (Agents as Tools, Swarm, Graph, Workflow)
β
Deploy production-ready agents to AgentCore
β
Deploy Strands agents to AWS Lambda with Function URLs
β
Optimize costs with S3 Vectors
β
Implement content safety with guardrails
β
Create async serverless pipelines
β
Monitor and observe agent behavior
β
Build interactive UIs for AI applications
β
Deploy full-stack applications with Terraform and CDK
β
Integrate Aurora Serverless with pgvector for RAG
β
Evaluate RAG quality with RAGAS metrics
β
Apply advanced RAG patterns (hybrid search, re-ranking, multi-collection)
Ready to build?
π¨ Quick Demo: cd Sample_UI_for && streamlit run app.py
π Learn: Start with 1a Basic Bedrock/1-bedrock_intro.ipynb
π Deploy: Follow guides in 3a Bedrock_Agents/
β‘ Lambda: Deploy a Strands agent in minutes with cd "3d Lambda" && ./deploy.sh
ποΈ Full Stack: Build the complete app with cd "3c Application" && terraform apply