variable "aws_region" {
  default     = "us-east-1"
  description = "AWS region"
}

variable "application_family" {
  description = "Application family"
  default     = "accounting"
}

variable "bucket_name" {
  description = "bucket name used in application"
  default     = "orcdbucket"
}

variable "ddb_write_max_attempts" {
  description = "Maximum write attempts to dynamo db"
  default = 10
}

variable "email_sender" {
  description = "Email sender used for notifications"
  default     = "donotreply@theorchard.com"
}

variable "environment" {
  description = "Available values: dev, qa, prod."
  default     = "prod"
}

variable "ignore_all_events" {
  description = "set this value to ignore messages sent to internal attachments lambda."
  default     = ""
}

variable "lambda_custom_reports_name" {
  description = "Name of the lambda used for generating custom reports"
  default     = "lambda-moneyhub-custom-reports"
}

variable "sqs_custom_reports_name" {
  description = "Name of the SQS queue used for generating custom reports"
  default     = "sqs-moneyhub-custom-reports"
}

variable "sns_internal_attachments_success_name" {
  description = "Name of the SNS service used for successful internal statement attachments uploads"
  default     = "prod_statement_attachments_success"
}

variable "sns_internal_attachments_error_name" {
  description = "Name of the SNS service used for successful internal statement attachments uploads"
  default     = "prod_statement_attachments_error"
}

variable "lambda_function_provisioned_concurrent_executions" {
  description = "Number of provisioned concurrent executions for lambda function. Puts lambda function to warm state, but may lead to high cost usage."
  default     = 1
}

variable "lambda_function_provisioned_concurrency_alias" {
  description = "Alias to provisioned version."
  default     = "provisioned"
}

variable "lambda_generate_attachments_name" {
  description = "Name of the lambda used for generating attachments"
  default     = "lambda-moneyhub-generate-attachments"
}

variable "sqs_generate_attachments_name" {
  description = "Name of the SQS queue used for generating attachments"
  default     = "sqs-moneyhub-generate-attachments"
}

variable "lambda_internal_attachments_name" {
  description = "Name of the lambda used for uploading internal attachments"
  default     = "lambda-moneyhub-internal-attachments"
}

variable "lambda_timeout" {
  description = "Execution timeout of the lambda function"
  default     = 900
}

variable "ows_service_profile_id" {
  description = "ID of the profile used when making requests to ows services"
  default     = "134124"
}

variable "ows_profile_roles" {
  description = "Profile role of the lambda used in orchard-roles header"
  default     = "administrator"
}

variable "ows_service_profile_type" {
  description = "Type of the profile used when making requests to ows services"
  default     = "AbacusProfile"
}

variable "secrets_manager_secret_names" {
  description = "List of secrets manager secrets to create"
  type        = list(string)
  default = [
    "SNOWFLAKE_KEY_PASSPHRASE",
    "SNOWFLAKE_PASSWORD",
    "SNOWFLAKE_PRIVATE_KEY"
  ]
}

variable "snowflake_account" {
  description = "Snowflake account"
  default     = "delphi.us-east-1"
}

variable "snowflake_database" {
  description = "Snowflake database"
  default     = "ROYALTY_ACCOUNTING"
}

variable "snowflake_schema" {
  description = "Snowflake schema"
  default     = "PROD"
}

variable "snowflake_warehouse" {
  description = "Snowflake warehouse"
  default     = "PROD_ETL_ACCOUNTING_WAREHOUSE"
}

variable "snowflake_role" {
  description = "Snowflake role"
  default     = "ROYALTYACCOUNTING_DB_PROD_SCHEMA_READWRITE"
}

variable "snowflake_user" {
  description = "User used to log in to Snowflake"
  default     = "LAMBDA_ROYALTY_ACCOUNTING"
}

variable "snowflake_private_key" {
  description = "Private key used by snowflake_user"
  default     = "SNOWFLAKE_PRIVATE_KEY"
}

variable "snowflake_key_passphrase" {
  description = "Passphrase used to decrypt the snowflake_private_key"
  default     = "SNOWFLAKE_KEY_PASSPHRASE"
}

variable "sqs_visibility_timeout" {
  description = "Timeout of the SQS queue"
  default     = 1080
}

variable "vpc_id" {
  default = "vpc-7f0e841a"
}

variable "vpc_subnet_ids" {
  default     = ["subnet-067a6b45b079d7296", "subnet-098b89d0c58c5693a"]
  description = "VPC subnet IDs where the lambda will execute"
  type        = list(string)
}

# Datadog
variable "notification_alerts_endpoint" {
  description = "DataDog alerts notification endpoint"
  default     = "@slack-moneyhub-alerts"
}

variable "notification_main_endpoint" {
  description = "DataDog main channel notification endpoint"
  default     = "@slack-moneyhub"
}

variable "lambda_error_monitor_message" {
  default = "{{#is_alert}}\n🚨We are receiving a high number of errors in {{service.name}}. It's currently over {{threshold}} within the last 5 mins. We should look into this as it may affect our customers generating documents.\n{{/is_alert}} \n\n{{#is_warning}}\n⚠️ Warning. We have just received a high number of error in {{service.name}}. Should we monitor it in case it goes over the alert threshold? We don't want it to affect our customers.\n{{/is_warning}} \n\n{{#is_recovery}}\n✅ {{service.name}} is back to normal🚀. \n{{/is_recovery}}\n\n"
}

variable "lambda_error_monitor_escalation_message" {
  default = "🚨Escalation Message🚨:\n\nWe're escalating this message into this channel @here as this alert has remained high for the last {{triggered_duration_sec}} seconds. This service - {{span.service}} - is extremely crucial for our customers and should be investigated **urgently**. Please stop what you are doing and take a look."
}

variable "lambda_p75_duration_monitor_message" {
  default = "{{#is_alert}}\n🚨 {{functionname.name}} p75 execution time is {{value}} ms, exceeding {{threshold}} ms (13 mins). At least 25% of invocations are within ~2 mins of the 15-minute AWS Lambda timeout. Investigate **urgently** to prevent dropped executions 🚨.\n{{/is_alert}}\n\n{{#is_recovery}}\n✅ {{functionname.name}} execution time has recovered 🚀.\n{{/is_recovery}}"
}

variable "lambda_p90_duration_monitor_message" {
  default = "{{#is_alert}}\n⚠️ {{functionname.name}} p90 execution time is {{value}} ms, exceeding {{threshold}} ms (13 mins). The slowest 10% of invocations are within ~2 mins of the 15-minute AWS Lambda timeout — please investigate before this escalates.\n{{/is_alert}}\n\n{{#is_recovery}}\n✅ {{functionname.name}} execution time has recovered 🚀.\n{{/is_recovery}}"
}

variable "team_handle" {
  default = "accounting"
}
