Enforcing Safety and Privacy Policies with Amazon Bedrock Guardrails
This lesson explains how Amazon Bedrock Guardrails lets you define safety and privacy policies once and apply them to the inputs and outputs of all your generative AI applications.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish the guardrail policies, such as content filters, denied topics and sensitive information filters.
- Describe where guardrails apply, including the ApplyGuardrail API.
Guardrail policies
Amazon Bedrock Guardrails checks both the prompts users send and the responses models return, using a set of policies that you configure. Content filters block hateful, insulting, sexual, violent and misconduct content, at a strength set separately for prompts and responses, and also cover images. The prompt attack filter detects jailbreak and prompt injection attempts. Denied topics block subjects you describe in plain language, such as investment advice for a banking assistant, and word filters block profanity and chosen words, such as competitor names.
Sensitive information filters detect personal information and custom patterns, then block it or mask it, for example replacing an email address with {EMAIL}. Contextual grounding checks block RAG answers that are not supported by the source documents or not relevant to the question, which catches hallucinations. Automated Reasoning checks use formal logic to verify that responses follow defined rules, such as an insurance policy's terms. The following table summarises the policies.
| Policy | What it does | Example |
|---|---|---|
| Content filters | Block hate, insults, sexual content, violence and misconduct, at a strength (none to high) set separately for prompts and responses; also cover images | Block abusive messages |
| Prompt attack filter | Detects jailbreaks and prompt injection | "Ignore your rules…" |
| Denied topics | Topics defined in plain language with sample phrases | "Investment advice" for a banking assistant |
| Word filters | Block profanity and custom words | Competitor names |
| Sensitive information filters | Detect PII and custom regex patterns, then block or mask them | Replace an email with {EMAIL} |
| Contextual grounding checks | Block responses not grounded in the source or not relevant to the query | Hallucinations in RAG answers |
| Automated Reasoning checks | Use formal logic to verify responses follow defined policies | HR or insurance rules |
Guardrail policies
Where guardrails apply
Amazon Bedrock Guardrails can be applied in several contexts. The following list describes where guardrails apply and how blocked requests are handled.
- Bedrock models, Agents and Knowledge Bases.
- The ApplyGuardrail API evaluates any text without calling a model, so it also protects models on SageMaker AI, in other clouds or on premises.
- Blocked requests return the message you configure; traces and metrics show which policy intervened.
The following diagram places the guardrail checks around a model.

Where guardrails apply
Configuring a guardrail for a banking assistant
A bank's assistant must stay helpful but safe. The team maps each requirement to a guardrail policy:
| Requirement | Guardrail policy | Setting |
|---|---|---|
| Never give investment advice | Denied topic | "Investment advice: recommendations to buy or sell specific investments" |
| Resist attempts to override its rules | Prompt attack filter | High strength on input |
| No abusive or violent content either way | Content filters | High for hate, insults, violence |
| Never show full account numbers | Sensitive information filter | Mask bank account numbers |
| Do not mention competitor banks by name | Word filter | List of competitor names |
| Answers must come from the bank's documents | Contextual grounding check | Block answers below a grounding threshold |
When a customer asks "Should I buy shares in ExampleCorp?", the guardrail intervenes and the customer sees the bank's configured message, such as "I cannot give investment advice, but I can connect you with an adviser." The same guardrail can protect a model hosted outside Bedrock through the ApplyGuardrail API.
Does a guardrail check what users send, what the model returns, or both?
Show answer
Both. A guardrail can evaluate the prompt before it reaches the model and the response before it reaches the user.
Exam Tips
Remember for the exam
- To stop a banking chatbot from giving investment advice, define a denied topic.
- To block jailbreak and injection attempts, use the prompt attack filter.
- To mask email addresses and phone numbers in responses, use a sensitive information filter.
- To detect hallucinations in RAG answers, use a contextual grounding check.
- To apply guardrails to models outside Bedrock, use the ApplyGuardrail API.
- To block competitor names or profanity, use word filters.