Lesson 1 of 4 Securing and Governing AI Workloads

Applying Content and Compliance Controls with Bedrock Guardrails

This lesson explains the policies a Bedrock guardrail can apply, where guardrails are applied and how to enforce them across an organisation.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe each guardrail policy and the requirement it addresses.
  • Explain how guardrails apply to Bedrock calls and to other models through ApplyGuardrail.
  • Choose a mechanism that enforces a guardrail on every model invocation.

Guardrail policies

A guardrail combines several policies, each optional. Content filters detect hate, insults, sexual content, violence, misconduct and prompt attacks (jailbreaks and prompt injection) at adjustable strengths. Denied topics describe subjects the application must not engage with, such as investment advice, in natural language with example phrases. Word filters block profanity and custom words. Sensitive information filters detect PII types (such as card numbers, national IDs, email addresses) and custom regular expressions, and either block or mask them.

Two policies address accuracy. Contextual grounding checks score whether a response is supported by the source passages and relevant to the question, which suits RAG applications. Automated Reasoning checks translate written rules, such as an HR or lending policy, into formal logic and verify whether a response is consistent with them, giving explainable, logic-based results.

Match the pairs

Guardrail policies

Exam skills 2.5.1

Match each requirement with the guardrail policy that meets it.

Log in to try this activity Interactive activities are free with an account.

Where guardrails apply

A guardrail is versioned and referenced on Converse and InvokeModel requests, on knowledge base and agent calls, or applied to any text with the ApplyGuardrail API, which lets the same policies protect models hosted on SageMaker AI or outside AWS. Each intervention is recorded in the response trace and in CloudWatch metrics, so compliance teams can monitor how often content is blocked and why.

The following table maps typical requirements to guardrail policies.

RequirementPolicy
Never reveal card numbers in answers, but still answerSensitive information filter with mask
Refuse investment adviceDenied topic
Block jailbreak attemptsContent filter for prompt attacks
Block answers not supported by retrieved documentsContextual grounding check
Verify answers against written eligibility rulesAutomated Reasoning check

The following diagram shows the two points at which a guardrail checks a model interaction.

Where a guardrail acts. The user's prompt is checked by the guardrail's input policies, such as content filters, denied topics and prompt attack detection, before it reaches the model. The model's response is checked again, for example to mask sensitive information or to block answers the source documents do not support. A blocked request or response returns a configured message instead.
The policies shown at each point are examples; any policy in the guardrail can apply to input, output or both.

Enforcing guardrails across an organisation

A guardrail only helps if it is used. Two mechanisms enforce it without relying on developers. The bedrock:GuardrailIdentifier condition key in an IAM policy or SCP denies inference requests that do not specify the approved guardrail (and version). Amazon Bedrock policies in AWS Organizations attach a guardrail to the organisation, OUs or accounts, so it is applied to model invocations in those accounts in addition to any application guardrail, with the most restrictive setting winning; member accounts need permission to apply the guardrail through its resource-based policy.

Scenario questions

Enforcing guardrails

Exam skills 2.5.1 · 2.3.4

Make sure guardrails are applied without relying on developers.

Log in to try this activity Interactive activities are free with an account.
Worked example

A banking assistant

A bank's assistant answers questions about accounts and products from a knowledge base. Compliance requires no investment advice, masked account and card numbers, protection against jailbreaks, and no answers that the source documents do not support, in every account that builds customer-facing AI.

The governance team creates one guardrail with a denied topic for investment advice, sensitive information filters with the mask action, the prompt attack filter at high strength and contextual grounding checks. It attaches the guardrail to the customer-facing OU with an Organizations Bedrock policy, and CloudWatch alarms on guardrail interventions alert the team if blocking suddenly increases, which may signal an attack or a broken prompt.

Check yourself

A team hosts a model on SageMaker AI but wants the company's Bedrock guardrail applied. Is that possible?

Show answer

Yes. The ApplyGuardrail API evaluates any text against a guardrail, so the application applies it to inputs before calling the endpoint and to outputs before returning them.

Exam Tips

Remember for the exam

  • Mask PII but still answer: sensitive information filter with the mask action.
  • Block unsupported answers in RAG: contextual grounding checks; logic-based policy verification: Automated Reasoning checks.
  • Every model call must use the approved guardrail: bedrock:GuardrailIdentifier condition or an Organizations Bedrock policy.
  • Apply the same policies to a self-hosted model: ApplyGuardrail API.