bedrock-rag
Purpose
Chunks local markdown corpora and syncs them into an Amazon Bedrock Knowledge Base for semantic retrieval.
Runbook
- Verify
aws,python3, andjqare in PATH, then validate credentials withaws sts get-caller-identity --no-cli-pager. - Confirm
BEDROCK_KB_IDandBEDROCK_MODEL_IDare set, and ensureAWS_REGIONmatches the Bedrock region hosting the knowledge base. - Run
scripts/chunk.sh SOURCE_DIRto split all.mdfiles into roughly 500-word JSONL chunks containingchunk_id,source_file, andcontent. - Review the chunk count before indexing; abort if the chunk count exceeds
1000unlessFORCE=1is explicitly set. - Run
scripts/index.sh CHUNKS_PATHto sync the chunk stream into the Bedrock Knowledge Base. The script ingests documents and then triggers a Bedrock ingestion job for auditable sync status. - Poll
aws bedrock-agent get-ingestion-jobuntil the job reportsCOMPLETE; abort onFAILEDorSTOPPED. - Run
scripts/query.sh "your question"to verify semantic retrieval and inspect the returned citations.
Stop conditions
- Abort if
aws sts get-caller-identityfails. - Abort if chunk count exceeds
1000unlessFORCE=1. - Never delete existing knowledge-base contents — only add or update documents.
- Abort if the Bedrock ingestion job returns
FAILEDorSTOPPED.
Output format
{
"chunks_synced": 128,
"kb_id": "KB12345678",
"model_id": "anthropic.claude-3-sonnet-20240229-v1:0",
"sync_status": "COMPLETE"
}
Example invocations
skills/bedrock-rag/scripts/chunk.sh docs > docs/.bedrock-rag.chunks.jsonlskills/bedrock-rag/scripts/index.sh docs/.bedrock-rag.chunks.jsonlskills/bedrock-rag/scripts/query.sh "What deployment steps are documented?"skills/bedrock-rag/scripts/run.sh docs --query "What changed in the onboarding guide?"