---
id: 17063
lang: en
title: "AWS shows how to secure a RAG support bot on Aurora PostgreSQL using eight responsible AI principles"
published_at: "2026-11-21 01:52:34"
source_name: "AWS Machine Learning Blog"
source_url: "https://aws.amazon.com/blogs/machine-learning/design-responsible-ai-controls-for-amazon-aurora-postgresql/"
canonical_url: "https://news.hamidun.com/en/news/17063"
categories: ["llm", "ethics"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# AWS shows how to secure a RAG support bot on Aurora PostgreSQL using eight responsible AI principles

> **Краткая суть (BLUF):** A support chatbot searches old tickets that contain names, phone numbers and order data, and it can reveal too much or make up a fact. AWS showed how to address the risks on Aurora PostgreSQL across eight responsible AI principles and walked through one of them in detail: explainability. Every answer is written to a log along with the retrieved fragments, similarity scores and citations. That way, a plain SQL query answers the question "why did the bot say that?"  • Titan Text Embeddings V2 computes 1,024-dimension vectors directly from SQL • Row-Level Security limits results to the current tenant's data only • pg_cron exports old log records to Amazon S3

Imagine a support bot that, when asked "Why is my last bill so high?", first searches for similar old tickets and knowledge base articles, then writes an answer based on them. This setup is called RAG: the model answers not from memory but from retrieved documents. It is fast, but it has two problems. The tickets contain names, phone numbers and order details, so the bot may expose data it shouldn't. And if an answer is made up, nobody can tell where it came from. AWS has published a guide proposing to solve this directly at the level of the Amazon Aurora PostgreSQL database. This is the first part of a series, and only one of the eight principles is covered in detail.

## The eight responsible AI principles and database features

AWS draws on eight dimensions of responsible AI from the Well-Architected Responsible AI Lens, Bedrock Guardrails and the Responsible Use of AI Guide. For each one, the article includes a table of specific tools. Here is how it applies to a support bot.

- **Fairness.** Answers should be equally good regardless of language, region or customer profile. Testing requires diverse test queries, metadata filters and multilingual tests.
- **Explainability.** Users and support staff should understand why the bot answered the way it did. To do this, the system logs the retrieved fragments, similarity scores and citations.
- **Privacy and security.** Personal data is masked before vectors are created. In addition, Row-Level Security, encryption, roles and IAM are applied.
- **Output safety.** Content filters, banned topics, protection against prompt injection and request rate limiting, mostly through Bedrock Guardrails.
- **Controllability.** Handoff of the conversation to a human, a feedback table, feature flags and an emergency kill switch.
- **Factuality and robustness.** The answer is tied to the retrieved data and a similarity threshold, and document versions are checked with CHECK constraints and triggers.
- **Governance.** An audit log via pgaudit, retention periods via pg_cron, an archive in Amazon S3 and tracking of model versions.
- **Transparency.** The user sees that they are talking to AI and receives the sources of the answer.

## How explainability works

First, documents are cleaned of personal data and converted into vectors, that is, numerical "fingerprints" of meaning. This is handled by the Aurora ML function aws_bedrock.invoke_model_get_embeddings with the Amazon Titan Text Embeddings V2 model (1,024 dimensions). The vectors are stored by the pgvector extension. Everything happens inside the database, with no separate ETL pipeline: Aurora ML calls Bedrock models and SageMaker endpoints directly from SQL.

Next, the path of a question. It arrives through API Gateway into Lambda and is turned into a vector by the same model used for the knowledge base, since otherwise the vectors cannot be compared. Aurora finds the nearest fragments by cosine distance and returns them with similarity scores. Row-Level Security leaves only the current tenant's data. Lambda assembles the prompt and labels each fragment as [Source N]. Guardrails check the input (content filters, banned topics, personal data), the model writes the answer, and a contextual grounding check confirms that the answer is based on the sources.

The key step comes last. Lambda writes to the chat_interactions table the question, the IDs of the retrieved fragments, their similarity scores, the sources actually cited, the Guardrails trace and the model ID. That is why a plain SQL query answers the question "why did the bot say that?" Old pg_cron records are archived to Amazon S3, logs and metrics go to CloudWatch, and API calls for audit are recorded by CloudTrail.

## Limitations and what to choose

The authors note upfront that the table of approaches consists of examples, that they depend on the task, and that the series so far covers only one area. The versions of pgvector, Aurora ML and Bedrock model support are updated independently, so minimum versions should be checked against the documentation. You also need a cluster parameter group with pgaudit and pg_cron (requiring a cluster restart), along with IAM roles for Bedrock and S3.

There is also a choice between a ready-made and a custom-built solution. Amazon Bedrock Knowledge Bases already provides RAG with citations and is simpler if its standard behavior is enough. A custom scheme makes sense when the origin of answers must be stored in-house. In that case, you can distinguish retrieved sources from cited ones, store similarity scores and Guardrails traces, query them via SQL and manage them under your own rules.

The practical takeaway for teams whose data already lives in Postgres: it is cheaper to build answer verifiability into the data schema from the start. Investigating customer complaints without logs costs far more. AWS promises to cover the remaining seven principles in upcoming parts.

---
- **Первоисточник:** [AWS Machine Learning Blog](https://aws.amazon.com/blogs/machine-learning/design-responsible-ai-controls-for-amazon-aurora-postgresql/)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/17063
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
