Blocking Harmful Prompts and Streaming Bedrock Guardrail Filters
Short answer
A Pre-check inputs with ApplyGuardrail, stream through InvokeModelWithResponseStream with the guardrail, post-check outputs, route flags to SQS, enforce via IAM.
Question
Which solution will meet these requirements?
Key Takeaways
The question tests full-lifecycle guardrail enforcement (pre-check, in-stream filter, post-check, routing, and IAM backstop); the trap is choosing an option that drops the pre-inference block or substitutes soft process controls for hard enforcement.
Amazon Bedrock Guardrails can be applied before, during, and after inference so a social messaging assistant blocks harmful prompts, filters streamed tokens in real time, and escalates flagged traffic for human review. This page confirms that a Step Functions workflow using ApplyGuardrail pre- and post-checks, InvokeModelWithResponseStream with the guardrail attached, an SQS review queue, and a bedrock:GuardrailIdentifier IAM condition is the only option meeting every stated requirement.
Common mistake: Option C is the most tempting wrong choice because it correctly uses InvokeModelWithResponseStream with the guardrail and a Lambda post-check, but it explicitly performs no pre-inference check, violating the requirement to block harmful prompts before model invocations.
Expert Analysis
Why the Answer Is Correct
Option A is the only choice that satisfies all four requirements simultaneously: a Lambda step calls the ApplyGuardrail API to reject harmful prompts before any model token is generated, the InvokeModelWithResponseStream step attaches the guardrail so streamed output is filtered as it is produced, and a second Lambda step runs ApplyGuardrail against the response for post-checking. Flagged items are handed to an Amazon SQS queue, which is the standard mechanism for routing cases to a human review workflow. Finally, the bedrock:GuardrailIdentifier IAM condition key makes guardrail attachment mandatory at the API call level, so no developer can bypass the approved safety policy. That combination guarantees that every inference, not just most inferences, complies.
Why the Other Options Are Wrong
Option B calls ApplyGuardrail before inference but then uses InvokeModel without streaming, which fails the explicit requirement to filter streamed model outputs in real time, and it delegates token suppression to the client UI where a user can simply inspect the raw response. Option C drops the pre-inference step entirely, so a harmful prompt still consumes model resources and is only caught after generation, directly contradicting the 'block harmful prompts before model invocations' requirement. Option D includes the right API sequence but relies on code reviews and other process controls instead of IAM enforcement, leaving compliance dependent on human discipline rather than a technical guarantee for every call.
Community Comment Notes
As TNT87 noted, option A's pre-check validation with Lambda and the ApplyGuardrail API 'ensures that harmful prompts are blocked immediately before consuming unnecessary model generation resources.' That reasoning matches the exam's emphasis on blocking before invocation, and the same comment's endorsement of answer A aligns with this analysis.
Official Reference
- https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html
- https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ApplyGuardrail.html
These links open the official vendor documentation in a new tab.
Exam Strategy
Read the requirement list first and tick off each clause against the option — streaming, pre-inference blocking, human routing, and enforcement each eliminate a specific distractor. IAM condition keys are the exam's tell for 'guaranteed compliance'; whenever an option offers only code reviews or client-side handling, treat it as a control gap.
Frequently Asked Questions
Why is skipping the pre-inference ApplyGuardrail check wrong here?
Why does an IAM condition key matter for Bedrock guardrails?
Discussion 1 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 1
-
TNT87 👍 1 Answered APre-check validation: Using an AWS Lambda function with the ApplyGuardrail API before invoking the model ensures that harmful prompts are blocked immediately before consuming unnecessary model generation resources
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All AIP-C01 Questions
Access 110 questions with complete answers and detailed explanations.
View Full AIP-C01 Practice Test →