# Generated by tools/hardened.py from ../t1. Edit t1 or the script; this file is regenerated. variable "name" { description = "Base name for the log group, bucket, key, alarms, guardrail, and saved queries." type = string default = "ai-model-logging" validation { condition = can(regex("^[a-z0-9-]{3,30}$", var.name)) error_message = "name must be 3-30 characters of lowercase letters, digits, or hyphens. The bucket prefix built from it is capped at 37." } } variable "trail_log_group" { description = "CloudWatch log group a multi-region CloudTrail trail delivers management events to, read and write, such as the Standard audit log template builds. logging-checked watches a read event." type = string } variable "retention_days" { description = "How long the invocation log group keeps records, and how long large data objects are kept in the bucket. 0 keeps them forever." type = number default = 365 validation { condition = contains([0, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, 3653], var.retention_days) error_message = "retention_days must be 0 or a CloudWatch Logs retention value of at least 90: 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, or 3653." } } variable "copy_retention_days" { description = "Days the full copy of every record is kept in the bucket, under its own prefix, before it expires." type = number default = 730 validation { condition = var.copy_retention_days >= 90 && floor(var.copy_retention_days) == var.copy_retention_days error_message = "copy_retention_days must be a whole number of at least 90." } } variable "log_image_data" { description = "Record images, and the documents Converse calls pass, in the bucket. Text is always recorded." type = bool default = true } variable "log_embedding_data" { description = "Record embeddings. They add volume and seldom help an investigation." type = bool default = false } variable "log_video_data" { description = "Record video. It adds volume, and is worth turning on only where video models are in use." type = bool default = false } variable "expected_principal_arns" { description = "IAM role ARNs for roles that change Bedrock settings as part of their job, such as the deployment pipeline and the role the daily drift plan uses. Every terraform plan reads the logging configuration, so name the plan role. Their calls do not alarm. Each entry is a blind spot." type = list(string) default = [] validation { condition = length(var.expected_principal_arns) <= 4 error_message = "List at most four. Each adds to a filter pattern that CloudWatch caps at 1,024 characters." } validation { condition = alltrue([for a in var.expected_principal_arns : can(regex("^arn:aws[a-z-]*:iam::[0-9]{12}:role/([A-Za-z0-9+=,.@_-]+/)*[A-Za-z0-9+=,.@_-]+$", a))]) error_message = "Each entry must be one IAM role ARN with no wildcard, such as arn:aws:iam::123456789012:role/deployer. A wildcard would hide every matching role." } } variable "model_caller_role_arns" { description = "IAM role ARNs for the roles that call Bedrock models: your applications. Any model call or batch job by another principal, in any Region, alarms. Leave empty to skip the alarm." type = list(string) default = [] validation { condition = length(var.model_caller_role_arns) <= 4 error_message = "List at most four. Each adds to a filter pattern that CloudWatch caps at 1,024 characters." } validation { condition = alltrue([for a in var.model_caller_role_arns : can(regex("^arn:aws[a-z-]*:iam::[0-9]{12}:role/([A-Za-z0-9+=,.@_-]+/)*[A-Za-z0-9+=,.@_-]+$", a))]) error_message = "Each entry must be one IAM role ARN with no wildcard, such as arn:aws:iam::123456789012:role/chat-backend. A wildcard would hide every matching role." } } variable "guardrail_strength" { description = "Filter strength for the guardrail's prompt attack filter and its five content filters." type = string default = "MEDIUM" validation { condition = contains(["LOW", "MEDIUM", "HIGH"], var.guardrail_strength) error_message = "guardrail_strength must be LOW, MEDIUM, or HIGH." } } variable "enforce_guardrail" { description = "Apply the guardrail to every model call in this account and Region, including calls that name no guardrail. Turn it on after testing: legitimate prompts can be blocked, and AWS says to check CloudTrail for AccessDenied after enabling it." type = bool default = false } variable "alert_topic_arn" { description = "An existing SNS topic for the alarms. If it is encrypted, its key policy must let cloudwatch.amazonaws.com use the key, or the alarms cannot publish. Leave empty to create one and subscribe alert_emails." type = string default = "" } variable "alert_emails" { description = "Addresses subscribed to a new topic, when alert_topic_arn is empty." type = list(string) default = [] validation { condition = var.alert_topic_arn != "" || length(var.alert_emails) > 0 error_message = "Set alert_topic_arn or give at least one address in alert_emails, or the alarms reach no one." } } variable "owner" { description = "Tag contract: accountable team." type = string default = "security-engineering" } variable "environment" { description = "Tag contract: environment." type = string default = "prod" } variable "extra_tags" { description = "Additional tags merged over the contract." type = map(string) default = {} }