Skip to content

New pattern - bedrock-guardrails-cross-account-cdk#3067

Open
NithinChandranR-AWS wants to merge 2 commits intoaws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-bedrock-guardrails-cross-account-cdk
Open

New pattern - bedrock-guardrails-cross-account-cdk#3067
NithinChandranR-AWS wants to merge 2 commits intoaws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-bedrock-guardrails-cross-account-cdk

Conversation

@NithinChandranR-AWS
Copy link
Copy Markdown

@NithinChandranR-AWS NithinChandranR-AWS commented Apr 20, 2026

Bedrock Guardrails Account-Level Enforcement

Creates a Bedrock Guardrail, versions it, and enables account-level enforcement. The guardrail automatically applies to ALL Bedrock calls in the account without specifying guardrailIdentifier.

Architecture: CDK creates Guardrail → versions via AwsCustomResource → enforces account-wide → Test Lambda demonstrates automatic enforcement

Key decisions:

  • AwsCustomResource for PutEnforcedGuardrailConfiguration (not in Lambda runtime SDK)
  • Content filters (HATE, INSULTS, SEXUAL, VIOLENCE, MISCONDUCT, PROMPT_ATTACK) + denied topic (investment advice)
  • Automatic cleanup on stack deletion

Test results:

  • Safe prompt (What is Amazon S3?) → full response
  • Violating prompt (What stocks should I buy?) → blocked with guardrail_intervened

TypeScript / AWS CDK

…count-level enforcement pattern

Creates a Bedrock Guardrail with content and topic filters, versions
it, and enables account-level enforcement via AwsCustomResource. Test
Lambda demonstrates automatic guardrail enforcement on all Bedrock
calls without specifying guardrailIdentifier.

Key features:
- Account-level guardrail enforcement via PutEnforcedGuardrailConfiguration
- AwsCustomResource for SDK commands not in Lambda runtime
- Content filters (HATE, INSULTS, SEXUAL, VIOLENCE, MISCONDUCT, PROMPT_ATTACK)
- Denied topic filter (investment advice)
- Test Lambda showing safe vs blocked responses
- Automatic cleanup on stack deletion
Replace wildcard resource with specific inference profile ARN and
foundation-model/* for least-privilege IAM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants