Bedrock Logging Parameter NotFunctioning As Documented. #4381
Labels
bedrock
closing-soon
This issue will automatically close in 4 days unless further comments are made.
Describe the bug
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock/client/put_model_invocation_logging_configuration.html
put_model_invocation_logging_configuration parameter is not handled correctly. The documentation states this:
'videoDataDeliveryEnabled': True|False
When using this parameter with a 'Boolean' value in Lambda I get this error
Parameter validation failed:\nUnknown parameter in loggingConfig: "videoDataDeliveryEnabled", must be one of: cloudWatchConfig, s3Config, textDataDeliveryEnabled, imageDataDeliveryEnabled, embeddingDataDeliveryEnable
Regression Issue
Expected Behavior
I expect this parameter to enable or disable logging of video data for Bedrock Invocations.
Current Behavior
Error
Reproduction Steps
Requires a properly configured S3 bucket, CloudWatch LogGroup, and BedrockLogginRole
Create a Lambda function with Environment Variables
LOG_GROUP_NAME = /aws/bedrock/model-invocation
LOGGING_ROLE_ARN = arn:aws:iam::123456789012:role/BedrockLoggingRole
S3_BUCKET_NAME = your-logging-bucket-name
S3_KEY_PREFIX = bedrock-logs/ # Optional
Use this code in the Lambda Function
import os
import boto3
from botocore.exceptions import ClientError
def lambda_handler(event, context):
# Initialize Bedrock client
bedrock = boto3.client('bedrock')
def verify_logging_configuration():
"""Helper function to verify the logging configuration"""
bedrock = boto3.client('bedrock')
Test with these inputs
{
"action": "configure",
"verify": true
}
Lambda Execution Role
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:PutModelInvocationLoggingConfiguration",
"bedrock:GetModelInvocationLoggingConfiguration"
],
"Resource": ""
},
{
"Effect": "Allow",
"Action": [
"iam:PassRole"
],
"Resource": "arn:aws:iam:::role/BedrockLoggingRole"
},
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:::*"
}
]
}
S3 Bucket Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowBedrockLoggingService",
"Effect": "Allow",
"Principal": {
"Service": "bedrock.amazonaws.com"
},
"Action": [
"s3:PutObject",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::your-bedrock-logs-bucket",
"arn:aws:s3:::your-bedrock-logs-bucket/"
],
"Condition": {
"StringEquals": {
"aws:SourceAccount": "YOUR_ACCOUNT_ID"
}
}
},
{
"Sid": "EnforceEncryptedTransport",
"Effect": "Deny",
"Principal": "",
"Action": "s3:",
"Resource": [
"arn:aws:s3:::your-bedrock-logs-bucket",
"arn:aws:s3:::your-bedrock-logs-bucket/"
],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
}
]
}
Possible Solution
No response
Additional Information/Context
No response
SDK version used
Boto3
Environment details (OS name and version, etc.)
Python 3.13
The text was updated successfully, but these errors were encountered: