# ElastiCache Redis for ows-coda chatbot conversation history.
# Dedicated instance — not shared with graphql-abacus or other services.
module "ows_coda_chatbot_cache" {
  source = "git@github.com:theorchard/terraform-elasticache.git//?ref=4.0.2"

  providers = {
    aws.dns = aws.networking
  }

  environment                = var.environment
  service_name               = "${var.service_name}-chatbot"
  application_family         = var.application_family
  cache_engine               = "redis"
  redis_engine_version       = "7.1"
  cache_subnet_group_name    = "${var.environment}-elasticache-subnet-group"
  cache_node_type            = "cache.t4g.micro"
  cache_parameter_group_name = "default.redis7"
  vpc_id                     = module.vpc_info.vpc_id

  # Encryption at rest — protects conversation history on disk/swap.
  cache_at_rest_encryption_enabled = true
  # Encryption in transit — requires app to connect via rediss:// (TLS).
  cache_transit_encryption_enabled = true
}

module "ows_coda_chatbot_cache_dashboard" {
  source = "git@github.com:theorchard/terraform-datadog.git//modules/elasticache?ref=6.18.1"

  environment        = var.environment
  service_name       = "${var.service_name}-chatbot"
  application_family = var.application_family
  teams              = ["coda-${var.environment}"]

  notification_endpoints            = local.datadog_notification_endpoints
  escalation_notification_endpoints = local.datadog_escalation_notification_endpoints
}
