c1.3 Filter inputs and outputs with Amazon Bedrock Guardrails
Put a versioned Bedrock guardrail in front of the model to block harmful content, denied topics, and prompt-injection patterns, and to redact PII on both inputs and outputs.
Implementation guidance
How to implement on AWS
Configure a guardrail with content filters, denied topics, and prompt-attack filters tuned to your risk tolerance; enable PII filters. Deploy a versioned guardrail and invoke it on every model call. Encrypt the guardrail with a customer managed key.
What a guardrail gives you
Amazon Bedrock Guardrails is a policy layer you put in front of the model so safety and privacy rules live outside your prompt and outside your application code. One guardrail can be reused across models and applications, giving you a consistent, auditable safety baseline. It enforces several policy types together:
- Content filters — block Hate, Insults, Sexual, Violence, Misconduct, and Prompt Attack (prompt injection / jailbreak) categories, with an adjustable strength per category.
- Denied topics — natural-language topics your application must refuse (e.g. "investment advice").
- Word filters — exact-match words/phrases to block (profanity, competitor names).
- Sensitive information filters — detect PII and either block the request or redact it from the response.
Create a versioned guardrail
Define the policies once and create a guardrail. The content-filter block below turns on prompt-attack detection on inputs and harmful-content filtering on both sides:
aws bedrock create-guardrail \
--name "prod-genai-guardrail" \
--description "Baseline safety + PII controls for the app" \
--blocked-input-messaging "Your request was blocked by our safety policy." \
--blocked-outputs-messaging "The response was blocked by our safety policy." \
--content-policy-config '{
"filtersConfig": [
{ "type": "PROMPT_ATTACK", "inputStrength": "HIGH", "outputStrength": "NONE" },
{ "type": "HATE", "inputStrength": "HIGH", "outputStrength": "HIGH" },
{ "type": "VIOLENCE", "inputStrength": "HIGH", "outputStrength": "HIGH" }
]
}' \
--sensitive-information-policy-config '{
"piiEntitiesConfig": [
{ "type": "EMAIL", "action": "ANONYMIZE" },
{ "type": "CREDIT_DEBIT_CARD_NUMBER", "action": "BLOCK" }
]
}'
Note:PROMPT_ATTACKonly supportsinputStrength(it is an input-side detection), so itsoutputStrengthmust beNONE.
Pin a version and apply it
create-guardrail returns a guardrailId. Publish an immutable version with create-guardrail-version, then reference guardrailIdentifier + guardrailVersion on every call — either as parameters to InvokeModel/Converse, or independently with the ApplyGuardrail API to screen text before you even invoke a model:
aws bedrock-runtime apply-guardrail \
--guardrail-identifier "gr-0abc123456789def0" \
--guardrail-version "1" \
--source "INPUT" \
--content '[{"text":{"text":"<user prompt to screen>"}}]'
Applying the guardrail before invocation lets you reject a bad prompt without paying for a model call.
Naming note: pin a specificguardrailVersionin production rather than the mutableDRAFT, so a policy change is a deliberate, reviewable deploy.
How it fits together
Acceptance criteria
Every inference path invokes a versioned guardrail; a test prompt-injection and a PII sample are blocked/redacted; guardrail activation metrics appear in CloudWatch.
Practical implementation
How this control is implemented in each reference architecture:
A versioned guardrail defined in the Generative AI account is applied to every InvokeModel call, so no inference path bypasses content, prompt-attack, and PII filters.
- In the Generative AI account, create a guardrail with content filters, denied topics, prompt-attack filters, and PII filters tuned to your risk tolerance, and publish a numbered version.
- Pass the guardrailIdentifier and guardrailVersion on every InvokeModel/Converse call from the application, and deny (via IAM condition) invocations that omit the guardrail.
- Encrypt the guardrail with the customer managed key and emit guardrail activation metrics to CloudWatch for monitoring.
How to validate: A test prompt-injection string and a PII sample are blocked/redacted; CloudWatch shows guardrail intervention metrics; an InvokeModel call without a guardrail is denied.
Avoid: Attaching the guardrail in the UI console but leaving direct SDK/API calls able to skip it. Enforce the guardrail on every path, ideally with an IAM condition, not by convention.
One versioned guardrail in the account is invoked on every model call from the generative AI tier, with filters enabled from day one.
- Create a guardrail with content, denied-topic, prompt-attack, and PII filters and publish a version; treat the version id as a deployable artifact.
- Wire the guardrail id/version into the application's Bedrock calls so every request and response passes through it; reject code paths that call the model without it.
- Encrypt the guardrail with the customer managed key and send intervention metrics to CloudWatch.
How to validate: A synthetic injection and a PII sample are blocked/redacted; CloudWatch shows guardrail metrics; no application code path calls the model without the guardrail.
Avoid: Shipping the app first and 'adding guardrails later'. Enable the guardrail from the first deploy; retrofitting it after launch leaves an exposed window.
Threats addressed
- Prompt injection embedding hidden instructions in user input.
- Sensitive data disclosure through model responses.
AWS services
Pricing
Guardrails are billed by the volume of text evaluated (per 1,000 text units) and by the policies enabled; sensitive-information and contextual-grounding checks are priced separately. See the Amazon Bedrock pricing page for current rates. See Detect and filter harmful content by using Amazon Bedrock Guardrails.
Framework mappings
OWASP GenAI/LLM Top 10 (2026)
- LLM01 Prompt Injection
- LLM02 Sensitive Information Disclosure
NIST AI Risk Management Framework (AI 100-1)
- MEASURE.2 AI systems are evaluated for trustworthy characteristics
- MANAGE.1 AI risks are prioritized, responded to and managed
AWS Well-Architected Generative AI Lens (Security)
- GENSEC02-BP01 Implement guardrails to mitigate harmful or incorrect model responses
- GENSEC04-BP02 Sanitize and validate user inputs to foundation models
Learning resources
References
- AWS AI Security Framework — AI application layer
AI Security Maturity Model