Blocking Harmful Prompts and Streaming Bedrock Guardrail Filters

Answer Correct answer: A — Pre-check inputs with ApplyGuardrail, stream through InvokeModelWithResponseStream with the guardrail, post-check outputs, route flags to SQS, enforce via IAM.

A social messaging company is building an AI chat assistant by using Amazon Bedrock. The company must ensure that every inference complies with an approved safety policy. The company wants to block harmful prompts before model invocations, filter streamed model outputs in real time, and route flagged cases for human review. Which solution will meet these requirements?

  1. Configure an AWS Step Functions workflow. Configure a step to use an AWS Lambda function to pre-check inputs by using the ApplyGuardrail API. Use an InvokeModelWithResponseStream API step that has the guardrail attached. Configure a second Lambda function step to post-check outputs by using the ApplyGuardrail API. Route flagged items to an Amazon SQS queue. Enforce guardrail use by using a bedrock:GuardrailIdentifier IAM condition. Correct Answer
  2. Configure an AWS Step Functions workflow. Configure a step to call the ApplyGuardrail API before inference. Then call the InvokeModel API without streaming and use the guardrail. Store the results in Amazon S3. Use the client UI to hide problematic tokens.
  3. Configure an AWS Step Functions workflow. Configure a step to use the InvokeModelWithResponseStream API that has the guardrail attached for in-stream filtering. Run an AWS Lambda post-check step by using the ApplyGuardrail API to check flagged cases. Do not perform pre-inference.
  4. Configure an AWS Step Functions workflow that includes steps to perform pre-checks and post-checks by using the ApplyGuardrail API and the InvokeModelWithResponseStream API. Attach the guardrail to the check steps. Use process controls such as code reviews instead of IAM enforcement to ensure that guardrails are always applied.

Community Insight

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.

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.

Community Discussion (1 comments)

TNT87 👍 1 Selected: A
Pre-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

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

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

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?

The question requires blocking harmful prompts before model invocations; option C skips that step, so unsafe inputs still reach and consume the foundation model.

Why does an IAM condition key matter for Bedrock guardrails?

A bedrock:GuardrailIdentifier IAM condition makes it impossible to invoke a model without a guardrail, so every inference is guaranteed to comply with the approved policy.

More AIP-C01 FAQ →

Related Analysis

Practice All AIP-C01 Questions

Access 110 questions with complete answers and detailed explanations.

View Full AIP-C01 Practice Test →

← Back to AIP-C01 Study Guide