Configuring Amazon Bedrock Guardrails Policies
This lesson describes each Amazon Bedrock Guardrails policy, which applies configurable safety and privacy controls to inputs and outputs independently of the model and prompt, and how guardrails are applied and versioned.
Learning outcomes
After completing this lesson, you will be able to:
- Configure content filters and prompt attack filters.
- Configure denied topics, word filters and sensitive information filters.
- Use contextual grounding and Automated Reasoning checks.
- Apply guardrail versions in API calls and with ApplyGuardrail.
Content filters and prompt attacks
Content filters detect and block harmful content in six categories: hate, insults, sexual, violence, misconduct (criminal activity) and prompt attack. Each category has a filter strength (none, low, medium or high) set separately for inputs and outputs; higher strength blocks more content, including lower-confidence detections, at the risk of more false positives. Content filters can also evaluate images for supported categories. The prompt attack filter detects jailbreak attempts, prompt injection and attempts to extract the system prompt, and applies to user input.
Denied topics, word filters and sensitive information
Denied topics are defined in natural language with a name, a definition and sample phrases, such as "Investment advice: recommendations about buying or selling specific securities". The guardrail blocks inputs or outputs about the topic regardless of wording. Word filters block exact words and phrases, such as competitor names, plus a managed profanity list.
Sensitive information filters detect personally identifiable information (PII) entity types, such as names, email addresses, phone numbers, credit card numbers and national identifiers, and custom regular expressions for organization-specific data such as account numbers. Each type is set to block the whole request or response, or to mask (anonymise) the value, replacing it with a placeholder such as {EMAIL}.
The following diagram maps each requirement to a policy in the guardrail.

Which guardrail policy?
Grounding and Automated Reasoning checks
Contextual grounding checks evaluate a response against a reference source, such as retrieved passages, and the user's query. They compute a grounding score (is the response supported by the source?) and a relevance score (does it answer the query?), and block responses below configured thresholds between 0 and 0.99. Automated Reasoning checks validate responses against a policy that Bedrock translates from documents (for example an HR or eligibility policy) into formal logic, and return findings that show whether a response is valid, invalid or unsupported, with explanations, so the application can correct or flag it.
The following diagram shows a contextual grounding check blocking a response.

Grounding and Automated Reasoning
Applying guardrails
A guardrail is created as a working draft and published as numbered versions. Applications attach a guardrail ID and version to Converse, InvokeModel, RetrieveAndGenerate, agents and flows; when it intervenes, the response is replaced with a configurable blocked message and the stop reason indicates a guardrail intervention. Trace output shows which policy triggered. In Converse, guardContent blocks mark which parts of the input to evaluate, so system instructions or trusted context are not filtered, and grounding sources and queries are marked for grounding checks.
The ApplyGuardrail API evaluates any text against a guardrail without invoking a model, so the same policies protect models on SageMaker AI, third-party providers, or intermediate steps of an agent. For streaming, guardrails evaluate output in chunks, synchronously or asynchronously. Guardrails can use cross-Region profiles for capacity and broader language support.
resp = brt.apply_guardrail(
guardrailIdentifier="gr-abc123", guardrailVersion="4", source="OUTPUT",
content=[{"text": {"text": model_output}}],
)
if resp["action"] == "GUARDRAIL_INTERVENED":
model_output = resp["outputs"][0]["text"] # blocked message or masked textThe following table summarises the guardrail policies.
| Policy | Detects | Typical use |
|---|---|---|
| Content filters | Hate, insults, sexual, violence, misconduct | Block harmful inputs and outputs |
| Prompt attack filter | Jailbreaks, prompt injection, prompt leakage | Protect system instructions |
| Denied topics | Natural-language topic definitions | Out-of-scope or prohibited subjects |
| Word filters | Exact words and profanity | Competitor names, banned terms |
| Sensitive information filters | PII types and regex patterns | Block or mask PII |
| Contextual grounding check | Ungrounded or irrelevant responses | Reduce RAG hallucinations |
| Automated Reasoning checks | Responses that contradict formal policy rules | Policy-accurate answers |
The following diagram shows where the guardrail evaluates a request and its response.

Applying a guardrail
A banking assistant
A bank's assistant must refuse investment advice, never reveal full card numbers, block abusive language and not answer from outside its retrieved documents.
One guardrail covers all four: a denied topic for investment advice, a sensitive information filter masking credit card numbers in outputs, content filters for insults and hate on inputs and outputs, and a contextual grounding check with grounding and relevance thresholds. It is attached by version to the RetrieveAndGenerate calls.
Which guardrail policy masks email addresses in responses?
Show answer
The sensitive information filter, set to mask that PII type.
Exam Tips
Remember for the exam
- Content filters have strengths per category for inputs and outputs.
- Denied topics block subjects defined in natural language.
- Sensitive information filters block or mask PII and regex matches.
- Contextual grounding checks score grounding and relevance against thresholds.
- ApplyGuardrail protects any model or text without invoking Bedrock models.