{"id":32531,"date":"2025-11-21T11:34:51","date_gmt":"2025-11-21T10:34:51","guid":{"rendered":"https:\/\/sii.pl\/blog\/?p=32531"},"modified":"2025-11-21T11:39:04","modified_gmt":"2025-11-21T10:39:04","slug":"how-to-build-a-secure-rag-genai-chatbot-on-aws-with-amazon-bedrock","status":"publish","type":"post","link":"https:\/\/sii.pl\/blog\/en\/how-to-build-a-secure-rag-genai-chatbot-on-aws-with-amazon-bedrock\/","title":{"rendered":"How to build a secure RAG GenAI chatbot on AWS with Amazon Bedrock"},"content":{"rendered":"\n<p>In this article, I outline the process of setting up the environment, integrating data retrieval with the foundation model, and deploying a chatbot capable of delivering accurate, context-aware responses.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>What is Amazon Bedrock?<\/strong><\/strong><\/h2>\n\n\n\n<p>Amazon Bedrock is an AWS service that enables the secure and scalable building and deployment of generative AI applications. It provides access to powerful foundation models from leading providers, all of which are managed on AWS infrastructure. Bedrock simplifies development by offering managed endpoints and integrations, fine-tuning capabilities, and enterprise-grade security.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Foundation models in Amazon Bedrock<\/strong><\/strong><\/h2>\n\n\n\n<p>Amazon Bedrock provides access to a broad and continually expanding set of state-of-the-art foundation models (FMs) from leading providers, all accessible via a single API and fully managed by AWS. This allows enterprises to pick the best models for their use case \u2013 whether for text, image, code, multimodal understanding, or embeddings.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Popular providers and models (as of October 2025)<\/strong><\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Anthropic Claude<\/strong>:Claude Opus, Claude Sonnet 4.5, Claude Haiku \u2013 Advanced text-generation models known for their conversational reasoning, safety, and quality of language understanding. Used for chatbots, enterprise QA, legal document drafting, and multi-step reasoning.<\/li>\n\n\n\n<li><strong>Amazon Titan<\/strong>: Titan Text, Titan Image Generator, Titan Embeddings, Titan Multimodal \u2013 Amazon&#8217;s own models for text generation, embedding, and image creation. Titan is valued for its enterprise support, speed, security\/compliance integration (e.g., with AWS IAM\/S3\/VPC), and versatility across various use cases, including summarization, search, content generation, translation, and recommendations.<\/li>\n\n\n\n<li><strong>Stability AI Stable Diffusion<\/strong>: State-of-the-art image generation from text prompts. Used for high-fidelity marketing asset production, UI\/UX prototyping, creativity tools, and gaming.<\/li>\n\n\n\n<li><strong>Meta Llama 2<\/strong>: Powerful large language models for code, dialogue, and general text. Llama 2 (13B, 70B version) is often used for multi-turn conversational AI, knowledge extraction, and chatbots in regulated industries.<\/li>\n\n\n\n<li><strong>AI21 Labs Jurassic-2<\/strong>: Known for high-quality, nuanced, multi-lingual text and content generation. Useful in the finance, research, and legal sectors for Q&amp;A, data extraction, summarization, and document processing.<\/li>\n\n\n\n<li><strong>Cohere Command &amp; Embed<\/strong>: Specializes in fast, privacy-centric content generation and semantic searches, including support for over 100 languages and efficient document clustering.<\/li>\n\n\n\n<li><strong>Alibaba Qwen3<\/strong> (new in 2025): Mixture-of-experts (MoE) and dense language models, unique for code-generation, repository analysis, hybrid agent workflows, and balancing cost\/performance for advanced use cases.<\/li>\n\n\n\n<li><strong>Hugging Face Open Models<\/strong> (via Bedrock Marketplace): Includes access to leading open-source models for more specialized or niche AI tasks, fine-tuning, and edge deployments.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>How to choose the right model?<\/strong><\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Anthropic Claude<\/strong> is preferred when you need the safest and most advanced conversational agents or nuanced document understanding.<\/li>\n\n\n\n<li><strong>Titan excels<\/strong> for scalable, highly integrated AWS-centric deployments.<\/li>\n\n\n\n<li><strong>Stable Diffusion<\/strong> is the top choice for high-quality, creative image generation.<\/li>\n\n\n\n<li><strong>Llama 2 and Jurassic-2<\/strong> are best for sophisticated text applications, including multi-language and complex document workflows.<\/li>\n\n\n\n<li><strong>Qwen3, Cohere, and HuggingFace<\/strong> models fill advanced, multilingual, private, or code-focused needs.<\/li>\n<\/ul>\n\n\n\n<p><strong>Conclusion: <\/strong>To choose the best model, evaluate the following elements:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>output quality (and safety),<\/li>\n\n\n\n<li>cost and latency per request,<\/li>\n\n\n\n<li>multi-language\/document support,<\/li>\n\n\n\n<li>integration with AWS services (IAM, S3, VPC, etc.),<\/li>\n\n\n\n<li>need for custom training (prompt engineering, fine-tuning),<\/li>\n\n\n\n<li>compliance or data locality requirements.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"482\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image1-1024x482.png\" alt=\"Amazon Bedrock Model catalog\" class=\"wp-image-32520\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image1-1024x482.png 1024w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image1-300x141.png 300w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image1-768x362.png 768w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image1-1536x723.png 1536w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image1-2048x964.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig. 1 Amazon Bedrock Model catalog<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Knowledge bases in Amazon Bedrock<\/strong><\/strong><\/h2>\n\n\n\n<p>Knowledge Bases in Amazon Bedrock are used to connect your AI chatbot to your enterprise data sources. With Knowledge Bases, your chatbot can answer company-specific questions by retrieving information from your own data rather than relying just on public or general sources.<\/p>\n\n\n\n<p>Bedrock supports multiple data source types: you can use Amazon S3 buckets to store files, manuals, or documentation, or connect directly with your Confluence wiki, where company-specific knowledge lives. Thanks to this, your chatbot can answer internal questions from IT, HR, or other departments, delivering accurate, context-aware information to users.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"479\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image2-1024x479.png\" alt=\"Sample knowledge base setup in Amazon Bedrock: S3, Confluence, and other data sources\" class=\"wp-image-32522\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image2-1024x479.png 1024w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image2-300x140.png 300w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image2-768x359.png 768w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image2-1536x718.png 1536w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image2-2048x958.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig. 2 Sample knowledge base setup in Amazon Bedrock: S3, Confluence, and other data sources<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Using vector databases for embeddings<\/strong><\/strong><\/h2>\n\n\n\n<p>To store and index your document embeddings, Amazon Bedrock supports various vector databases (vector stores). These stores are critical for enabling fast similarity searches and hybrid retrieval over your company data.<\/p>\n\n\n\n<p>You can use:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Amazon OpenSearch Serverless,<\/li>\n\n\n\n<li>Amazon S3 Vectors,<\/li>\n\n\n\n<li>Aurora PostgreSQL,<\/li>\n\n\n\n<li>Neptune Analytics (GraphRAG) and more.<\/li>\n<\/ul>\n\n\n\n<p>In this project, we chose <strong>Amazon OpenSearch Serverless<\/strong> for our vector database. OpenSearch Serverless is fully managed, offers high performance at scale, and integrates natively with AWS security and monitoring tools. <strong>It&#8217;s ideal for RAG scenarios<\/strong> where low-latency access to context and scalability are key priorities.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"315\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image3-1024x315.png\" alt=\"Selecting a vector database in Amazon Bedrock: OpenSearch, S3 Vectors, Aurora, Neptune, and more\" class=\"wp-image-32524\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image3-1024x315.png 1024w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image3-300x92.png 300w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image3-768x236.png 768w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image3-1536x472.png 1536w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/image3-2048x629.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig. 3 Selecting a vector database in Amazon Bedrock: OpenSearch, S3 Vectors, Aurora, Neptune, and more<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Synchronizing your knowledge base data<\/strong><\/strong><\/h2>\n\n\n\n<p>After creating your knowledge base in Amazon Bedrock, you need to synchronize your data from the connected source, such as Confluence or your internal wiki. <\/p>\n\n\n\n<p>The synchronization process uploads and indexes your documents, allowing them to be accessed by the AI chatbot for retrieval and answering user questions. The operation usually takes a few minutes, depending on the size and number of files in your source. Large knowledge bases may require more time, but the synchronization is a one-time process and can be automated. Once complete, your chatbot can immediately search and respond to enterprise-specific queries using the freshly indexed data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Making your chatbot available: Deploying the Bedrock Agents API<\/strong><\/strong><\/h2>\n\n\n\n<p>After verifying that your model and Knowledge Base are working correctly, it&#8217;s time to make your chatbot available to users and applications by exposing the API.<\/p>\n\n\n\n<p>Amazon Bedrock provides <strong>Agents for Bedrock Runtime<\/strong> and the powerful <strong>RetrieveAndGenerate<\/strong> API to enable integration.<\/p>\n\n\n\n<p><strong>Key API features:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>RetrieveAndGenerate<\/strong> (<a href=\"https:\/\/docs.aws.amazon.com\/bedrock\/latest\/APIReference\/API_agent-runtime_RetrieveAndGenerate.html\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >API documentation<\/a>): This endpoint retrieves relevant context from your Knowledge Base and generates answers using your selected foundation model (e.g., Claude Sonnet 4.5). It&#8217;s the main engine behind RAG chatbots on Bedrock.<\/li>\n\n\n\n<li><strong>Agents for Amazon Bedrock Runtime<\/strong> (<a href=\"https:\/\/docs.aws.amazon.com\/bedrock\/latest\/APIReference\/API_Operations_Agents_for_Amazon_Bedrock_Runtime.html\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >API overview<\/a>): Agents let you manage models, documents, knowledge bases, and expose API endpoints to internal or external applications.<\/li>\n\n\n\n<li><strong>Python integration (boto3):<\/strong> Example for programmatic access <a href=\"https:\/\/boto3.amazonaws.com\/v1\/documentation\/api\/latest\/reference\/services\/bedrock-agent-runtime\/client\/retrieve_and_generate.html\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >boto3 retrieve_and_generate implementation<\/a>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><strong>How does it work?<\/strong><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Your chatbot is exposed as a REST API endpoint. Applications, websites, and users can send POST requests to it with natural language queries.<\/li>\n\n\n\n<li>The <strong>Agents for Bedrock Runtime<\/strong> automatically fetches data (using RAG) from your private company sources (Wiki, Confluence, S3 docs) and returns a generated, contextual answer.<\/li>\n\n\n\n<li>You can embed this API in MS Teams, Slack, intranet portals, HR or IT systems, or public-facing apps. Bedrock supports secure authentication, role-based access, and integrations with enterprise tools.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><strong>Typical use cases<\/strong><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Internal company chatbot answers HR or IT questions by searching your own docs, not just public knowledge.<\/li>\n\n\n\n<li>Automated handling of FAQs, ticket triage, onboarding, or support queries using company data.<\/li>\n\n\n\n<li>Real-time access to curated enterprise knowledge for employees, contractors, or customers.<\/li>\n<\/ul>\n\n\n\n<p><strong>Full API documentation<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.aws.amazon.com\/bedrock\/latest\/APIReference\/welcome.html\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >Bedrock API Reference (full)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.aws.amazon.com\/bedrock\/latest\/userguide\/service_code_examples_bedrock-agent-runtime_scenarios.html\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >Scenarios and code examples<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/boto3.amazonaws.com\/v1\/documentation\/api\/latest\/reference\/services\/bedrock-agent-runtime.html\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >Sample Python client for Bedrock Agents<\/a><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/sii.pl\/en\/job-ads\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"737\" height=\"170\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/praca-EN-k.jpg\" alt=\"job\" class=\"wp-image-32533\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/praca-EN-k.jpg 737w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/praca-EN-k-300x69.jpg 300w\" sizes=\"(max-width: 737px) 100vw, 737px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Summary<\/strong><\/strong><\/h2>\n\n\n\n<p>Once your chatbot is configured, synchronize your Knowledge Base and then expose the API endpoint using Bedrock Agents for Runtime. This way, your users will be able to get instant, enterprise-specific answers directly from your company data \u2013 securely and at scale.<\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-left kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;32531&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;2&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;11&quot;,&quot;greet&quot;:&quot;&quot;,&quot;legend&quot;:&quot;5\\\/5 ( votes: 2)&quot;,&quot;size&quot;:&quot;18&quot;,&quot;title&quot;:&quot;How to build a secure RAG GenAI chatbot on AWS with Amazon Bedrock&quot;,&quot;width&quot;:&quot;139.5&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} ( {votes}: {count})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 139.5px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 14.4px;\">\n            5\/5 ( votes: 2)    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this article, I outline the process of setting up the environment, integrating data retrieval with the foundation model, and &hellip; <a class=\"continued-btn\" href=\"https:\/\/sii.pl\/blog\/en\/how-to-build-a-secure-rag-genai-chatbot-on-aws-with-amazon-bedrock\/\">Continued<\/a><\/p>\n","protected":false},"author":755,"featured_media":32529,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","inline_featured_image":false,"footnotes":""},"categories":[1319],"tags":[3742,2167,1520,1336,1442],"class_list":["post-32531","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-soft-development","tag-rag-en","tag-aws-en","tag-tool","tag-cybersecurity-en","tag-ai-en"],"acf":[],"aioseo_notices":[],"republish_history":[],"featured_media_url":"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2025\/11\/AI_2.jpg","category_names":["Soft development"],"_links":{"self":[{"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/posts\/32531"}],"collection":[{"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/users\/755"}],"replies":[{"embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/comments?post=32531"}],"version-history":[{"count":1,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/posts\/32531\/revisions"}],"predecessor-version":[{"id":32535,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/posts\/32531\/revisions\/32535"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/media\/32529"}],"wp:attachment":[{"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/media?parent=32531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/categories?post=32531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/tags?post=32531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}