Overview
The AWS Bedrock Guardrail plugin is a robust content filtering system that leverages Amazon Bedrock’s guardrail capabilities to protect your AI gateway. It provides comprehensive content moderation through Amazon’s pre-trained models and customizable guardrails, ensuring that content passing through your gateway adheres to specified policies and guidelines. The plugin integrates seamlessly with AWS Bedrock’s guardrail system, which offers three primary types of protection:- Topic Policy: Controls allowed and disallowed topics
- Content Policy: Filters potentially harmful or inappropriate content
- Sensitive Information Policy: Detects and protects against exposure of sensitive data
Features
- Topic-based Filtering:
- Block specific topics or subject matters
- Customizable topic policies
- Fine-grained control over allowed content
- Content Moderation:
- Detection of harmful content
- Customizable content policies
- Multiple filter types for different content categories
- PII Protection:
- Detection of sensitive information
- Protection against data leakage
- Customizable PII entity types
- Action Configuration:
- Customizable block messages
- Detailed error reporting
- Comprehensive logging
Authentication
The AWS Bedrock Guardrail plugin supports two authentication methods for connecting to AWS services. Proper authentication configuration is essential for the plugin to access AWS Bedrock guardrail services.Authentication Methods
1. AWS Access Key/Secret Key Authentication
This is the traditional method using AWS access keys. Best suited for development environments or when using dedicated service accounts.2. IAM Role-Based Authentication (Recommended)
This method uses AWS STS (Security Token Service) to assume an IAM role. This is the recommended approach for production environments as it provides better security through temporary credentials.Authentication Configuration Parameters
Credentials Configuration
Parameter | Description | Required | Authentication Method |
---|---|---|---|
aws_access_key | AWS access key ID | Yes* | Access Key/Secret |
aws_secret_key | AWS secret access key | Yes* | Access Key/Secret |
aws_region | AWS region for Bedrock service | Yes | Both |
aws_session_token | Optional AWS session token for temporary creds | No | Access Key/Secret |
use_role | Enable IAM role-based authentication | No | Role-based |
role_arn | ARN of the IAM role to assume | Yes** | Role-based |
session_name | Name for the assumed role session | No | Role-based |
use_role
is false or not specified**Required when
use_role
is true
Authentication Best Practices
Security Recommendations
- Use IAM Roles in Production: Role-based authentication is more secure as it uses temporary credentials and follows AWS security best practices.
-
Principle of Least Privilege: Ensure the IAM user or role has only the minimum permissions required:
- Region Selection: Choose the AWS region closest to your deployment for optimal performance and compliance.
-
Credential Management:
- Never hardcode credentials in configuration files
- Use environment variables or secure credential management systems
- Rotate access keys regularly when using access key authentication
Environment-Specific Configurations
Development Environment:Configuration Examples
Basic Configuration
The basic configuration provides essential content filtering with a specified guardrail:Configuration Parameters
Parameter | Description | Required |
---|---|---|
guardrail_id | AWS Bedrock Guardrail identifier | Yes |
version | Guardrail version (defaults to “1”) | No |
actions.message | Custom message template for blocked content | No |
Security-Focused Configuration
For environments requiring strict security controls:Example Use Cases
1. Content Moderation Gateway
Create a gateway that moderates content using AWS Bedrock’s guardrails:2. Topic Policy Protection
The topic policy feature allows you to control which subjects or topics are allowed or denied in the content. When a topic is blocked, the plugin will return a specific error message indicating which topic violated the policy. Example configuration focusing on topic policies:3. Sensitive Information Protection
The plugin can detect and block content containing sensitive information such as PII (Personally Identifiable Information):Best Practices
1. Guardrail Configuration
• Use appropriate guardrail IDs for your use case • Test guardrails thoroughly before deployment • Keep guardrail versions consistent across environments2. Error Handling
• Implement descriptive error messages • Log policy violations appropriately • Review and update policies regularly3. Performance Optimization
• Use appropriate AWS region for reduced latencyPerformance Considerations
The AWS Bedrock Guardrail plugin is designed for optimal performance while providing robust content filtering capabilities. The plugin maintains a single AWS client instance per plugin instance, reducing the overhead of creating new connections for each request. The implementation includes efficient error handling and logging mechanisms to ensure reliable operation in production environments. Key performance features include:- Efficient AWS client management
- Optimized request handling
- Comprehensive logging for debugging
- Minimal memory footprint
- Fast response times for content evaluation