Your team has 400 PDFs of policies and runbooks, and people keep asking the same questions in chat. A RAG chatbot answers from those files and shows which page each answer came from.
The quickest way to build RAG on AWS is Amazon Bedrock Knowledge Bases. You point it at your documents, it handles splitting, embedding, storage and search, and a model writes the answer from what it finds.
If Bedrock is new to you, read what Amazon Bedrock is first.
Last checked against the Amazon Bedrock Knowledge Bases docs and the Bedrock pricing page on December 4, 2026.
| Your situation | Pick this |
|---|---|
| You want RAG working this week with no database to run | Bedrock Managed Knowledge Base |
| Docs live in SharePoint, Confluence, Google Drive or OneDrive | Managed (it has native connectors) |
| You already run OpenSearch, Aurora PostgreSQL or Pinecone | Customer-managed knowledge base |
| You need full control over chunking, parsing and the index | Customer-managed knowledge base |
This post contains affiliate links. As an Amazon Associate, Stepstocloud.com earns from qualifying purchases.
If you’ll own this chatbot after launch, the retrieval and evaluation chapters of AI Engineering by Chip Huyen explain why answers go wrong and how to measure it.

How RAG on AWS works in one picture
Retrieval augmented generation means the model looks things up before it answers. It doesn’t learn your documents; it reads the relevant pieces at question time.
There are two phases:
- Ingestion (once, then on every change): files are parsed into text, split into chunks, turned into vectors (lists of numbers that capture meaning) and stored in an index.
- Each question: the question becomes a vector, the index returns the closest chunks, and those chunks go into the prompt with an instruction to answer only from them.

Bedrock’s default chunking splits text into chunks of about 300 tokens and never breaks a sentence. Fixed-size, hierarchical and semantic chunking are there if your documents need them.
The big advantage over fine-tuning: when a policy changes, you update one file and sync. No model retraining. Our Bedrock vs SageMaker AI comparison covers when training your own model does make sense.
Managed or customer-managed knowledge base?
Bedrock now offers two kinds of knowledge base, and AWS recommends the managed one for most teams.

With a Bedrock Managed Knowledge Base, AWS runs the index, the embedding model and the reranker. It has seven connectors: S3, SharePoint, Confluence, Web Crawler, Google Drive, OneDrive and Custom.
With a customer-managed knowledge base, you bring the vector store and look after it. Supported stores include:
- Amazon OpenSearch Serverless and OpenSearch Service managed clusters
- Amazon S3 Vectors (low-cost vector storage in S3)
- Amazon Aurora PostgreSQL
- Amazon Neptune Analytics (for GraphRAG)
- Pinecone, Redis Enterprise Cloud and MongoDB Atlas
The rest of this guide builds the managed version, because it has the fewest moving parts. The steps for a customer-managed one are the same apart from creating the vector store first.
Before you start
- An AWS account and an IAM user or role that can create knowledge bases. Never use the root user for this; see our IAM introduction.
- A Region where the managed knowledge base is offered. The docs keep a Region list; this guide uses US East (N. Virginia), us-east-1.
- Python 3 with boto3, and the AWS CLI v2.
- Your documents in a supported format: .txt, .md, .html, .doc/.docx, .csv, .xls/.xlsx or .pdf, each 50 MB or smaller (the data source requirements list them).
Step 1: Put your documents in S3
Create a bucket in the same Region and copy the files in. Keep one folder per topic; it makes metadata filters easier later. New to buckets? Start with what Amazon S3 is.
aws s3 mb s3://my-rag-docs-111122223333 --region us-east-1
aws s3 cp ./company-docs s3://my-rag-docs-111122223333/policies/ --recursiveClean the files first. Scanned PDFs without text, duplicate versions and 300-page exports with one useful page all make answers worse.
Step 2: Create the managed knowledge base
In the console, the managed version lives under Amazon Bedrock AgentCore: Built-in tools > Knowledge Base > Create Managed Knowledge Base.
- Give it a name. Leave the embedding model on Managed (the default needs no model access request).
- Let the console create a new service role.
- Under Data source, choose Amazon S3 and select your bucket and folder.
- Leave parsing on the managed parser and chunking on Default.
- Choose Create Knowledge Base and wait 2 to 5 minutes.
From the CLI, the same thing is one call with a small config file. Replace the role ARN with your own.
# kb-config.json
{ "type": "MANAGED", "managedKnowledgeBaseConfiguration": { "embeddingModelType": "MANAGED" } }
aws bedrock-agent create-knowledge-base \
--name policies-kb \
--role-arn arn:aws:iam::111122223333:role/BedrockKBRole \
--knowledge-base-configuration file://kb-config.json \
--region us-east-1The managed knowledge base also plugs into AgentCore Gateway, so an agent can call it as a tool without extra code.
Step 3: Sync the data
Nothing is searchable until you sync. In the console, open the knowledge base and choose Sync in the Data source section. From the CLI:
aws bedrock-agent start-ingestion-job \
--knowledge-base-id KB12345678 \
--data-source-id DS12345678 \
--region us-east-1Syncs are incremental: later runs only process files you added, changed or deleted. Run one after every change to the bucket, or schedule it.

Step 4: Test it in the console
Open the knowledge base and use the test window. First turn off “Generate responses” to see the raw chunks it finds; if those are wrong, no model will fix the answer.
Then turn generation on, pick a model, and ask a question your documents answer. Each sentence in the reply gets a footnote you can click to see the source excerpt.
Step 5: Call it from Python
This script retrieves the top chunks, then asks a model to answer only from them and cite them.
It uses the Retrieve API and the Converse API, which works with any Bedrock chat model. Copy a model ID from the Bedrock model catalog into MODEL_ID.
import boto3
REGION = "us-east-1"
KB_ID = "KB12345678"
MODEL_ID = "paste-a-model-id-from-the-bedrock-catalog"
kb = boto3.client("bedrock-agent-runtime", region_name=REGION)
llm = boto3.client("bedrock-runtime", region_name=REGION)
def ask(question):
hits = kb.retrieve(
knowledgeBaseId=KB_ID,
retrievalQuery={"text": question},
)["retrievalResults"][:5]
sources = "\n\n".join(
f"[{i + 1}] {h['content']['text']}" for i, h in enumerate(hits)
)
prompt = (
"Answer using only the sources below and cite them like [1]. "
"If the answer is not in the sources, say you don't know.\n\n"
f"Sources:\n{sources}\n\nQuestion: {question}"
)
reply = llm.converse(
modelId=MODEL_ID,
messages=[{"role": "user", "content": [{"text": prompt}]}],
inferenceConfig={"maxTokens": 500, "temperature": 0.2},
)
return reply["output"]["message"]["content"][0]["text"]
print(ask("How many days of annual leave can I carry over?"))On a managed knowledge base, the Retrieve call uses hybrid search (keyword plus semantic) and the managed reranker by default. The Retrieve guide shows how to switch reranking off or use your own model.
On a customer-managed knowledge base you can also call RetrieveAndGenerate, which does both steps in one request and returns citations. Our Amazon Bedrock tutorial covers API keys and the Converse API in more depth.
What a small RAG chatbot costs
These rates come from the Amazon Bedrock pricing page on December 4, 2026, for the managed knowledge base. The chunking guide explains why chunk size changes how many tokens each answer sends.
| Managed knowledge base item | Price |
|---|---|
| Index storage | $5.00 per GB of raw data per month |
| Parsing, managed embeddings, managed reranking | $0 |
| Standard retrieval (Retrieve API) | $1.00 per 1,000 calls |
| Agentic retrieval (built-in planner) | $4.00 per 1,000 calls + $1.00 per 1,000 underlying Retrieve calls |

Worked example: 2 GB of documents and 30,000 questions a month, answered by Claude Haiku 5.5 at $0.10 per million input tokens and $0.50 per million output tokens (global routing).
Each answer sends about 3,000 tokens in and gets 300 back.
| Line item | Monthly cost |
|---|---|
| Index storage: 2 GB × $5 | $10.00 |
| Retrieval: 30,000 calls × $1 per 1,000 | $30.00 |
| Model input: 90 million tokens × $0.10 per million | $9.00 |
| Model output: 9 million tokens × $0.50 per million | $4.50 |
| Total | about $53.50 |
Notice that retrieval is the biggest line, not the model. Caching common answers or skipping retrieval for small talk (“hi”, “thanks”) cuts it fastest. Our Amazon Bedrock pricing guide compares the model rates.
Customer-managed knowledge bases bill differently: you pay for the vector store you run (an OpenSearch Serverless collection, for example) plus the embedding model, so price that store before you choose it.
Troubleshooting RAG on AWS
| Symptom | Likely cause | Fix |
|---|---|---|
| Answers ignore a document you just added | The data source wasn’t synced | Run Sync or start-ingestion-job again |
| Retrieve returns nothing useful | Scanned PDFs with no text, or files over 50 MB | Use text PDFs, split big files, check the sync warnings |
| Citations show no page numbers | No chunking was chosen | Use Default or fixed-size chunking |
| A whole table comes back instead of one row | Bedrock returns the full table as context for chunks inside it | Expected; for row-level results pre-split the table yourself |
| Fewer results than numberOfResults | Chunks sharing the same context are merged | Normal behavior; raise the number if you need more |
| The model invents an answer | The prompt allows it, or retrieval found weak chunks | Tell it to say “I don’t know”, lower temperature, check raw chunks first |
One more: Bedrock Guardrails check the question and the model’s answer, but not the retrieved chunks. Keep sensitive files out of the bucket rather than relying on a guardrail to hide them.
Books for building RAG apps

AI Engineering (Chip Huyen)
RAG design, evaluation and the failure modes you’ll meet once real users start asking questions.
Check price on Amazon
Hands-On Large Language Models (Alammar and Grootendorst)
Clear diagrams of embeddings, semantic search and retrieval, the ideas under every knowledge base.
Check price on AmazonWhen it’s live, set a billing alert before you open the chatbot to the whole company. Retrieval calls scale with every question.

Frequently asked questions
What is RAG on AWS?
RAG on AWS means retrieval augmented generation built with AWS services, usually Amazon Bedrock Knowledge Bases. Your documents are split, embedded and indexed, and each question retrieves the most relevant chunks so a Bedrock model can answer from them with citations.
Do I need a vector database for Bedrock Knowledge Bases?
Not with a Bedrock Managed Knowledge Base, which runs its own index. A customer-managed knowledge base needs a vector store you choose, such as OpenSearch Serverless, Amazon S3 Vectors, Aurora PostgreSQL, Pinecone, Redis Enterprise Cloud or MongoDB Atlas.
How much does a Bedrock knowledge base cost?
A managed knowledge base costs $5 per GB of raw data per month for index storage and $1 per 1,000 Retrieve calls. Parsing, embeddings and reranking with the managed models are free. Model tokens for writing the answer are billed separately.
Is RAG better than fine-tuning?
For answering questions from documents that change, usually yes. RAG reads the current files at question time and can cite them, while fine-tuning bakes knowledge into a model and needs retraining whenever the facts change.
Which file types can a knowledge base read?
Text, Markdown, HTML, Word, CSV, Excel and PDF files, each up to 50 MB. Managed knowledge bases can also index images, audio and video when advanced indexing is turned on.
How often should I sync my knowledge base?
Sync after every change to the source files, or on a schedule that matches how often they change. Syncs are incremental, so Bedrock only processes files that were added, changed or deleted since the last run.
Conclusion
RAG on AWS no longer means stitching together a vector database, an embedding job and a search service yourself. A Bedrock Managed Knowledge Base does that part, and you write a few lines of Python around it.
- Start with documents in S3, a managed knowledge base and the default chunking.
- Sync after every change; syncs only process what changed.
- Check the raw retrieved chunks before blaming the model.
- Budget for storage ($5 per GB a month) and retrieval ($1 per 1,000 calls) as well as tokens.
- Move to a customer-managed knowledge base only when you need a specific vector store or full control.
Recommended reading
- What is Amazon Bedrock AgentCore?
- AWS generative AI tools: which to use for what
- AWS Certified AI Practitioner study guide
- How much does AWS cost?
I am an Amazon Web Services Professional, having more than 11 years of experience in AWS and other technologies. Extensively working in various AWS tools like S3, Lambda, API, Kinesis, Load Balancers, EKS, ECS, and many more. Working as a Solution Architect and Technology Lead for Architecting and implementing the same for different clients. He provides expert solutions around the world and especially in countries like the United States, Canada, United Kingdom, Australia, New Zealand, etc. Check out the complete profile on About us.
