IAM Service Role: Allows Bedrock service to write logs to CloudWatch and S3
Custom Resource: Lambda-based custom resource that configures Bedrock logging settings via API calls
Token Usage Alarms: (Optional) CloudWatch alarms on Bedrock InputTokenCount and OutputTokenCount, per model (summed across the model IDs listed) and/or account-wide
SNS Topic: (Optional) Alarm notification topic encrypted with the module KMS key, with email subscriptions, a topic policy and key grant letting this module's token alarms publish, and SSM parameters for its name and ARN
Configuration Options
enableAuditLoggingToS3: Enable S3 bucket creation and logging for model invocation audit logs
enableAuditLoggingToCloudwatch: Enable CloudWatch Log Group creation and logging for model invocation audit logs
At least one of these options must be enabled.
tokenUsageAlarms: (Optional) Alarms on model token use in the account: models (per model, up to 10 model IDs each) and/or accountTotal, each with inputTokenThreshold and/or outputTokenThreshold; a notification target (notificationTopicArn, or createNotificationTopic with notificationEmails); and periodSeconds (a multiple of 60), evaluationPeriods, and datapointsToAlarm. Token metrics count every caller in the account and Region.
Logging Capabilities
The construct enables comprehensive logging of Bedrock model invocations including:
Text data delivery
Image data delivery
Embedding data delivery
Video data delivery
S3 Configuration
When S3 logging is enabled:
Creates encrypted S3 bucket with naming pattern: bedrock-logs-{account}-{region}
Logs stored with prefix: bedrock-model-invocation-logs/bedrock-model-invocation-{region}
Bucket policy allows Bedrock service to write objects