variable "cluster_id" {
  description = "Replication group ID"
  type        = string
}

variable "engine" {
  description = "Cache engine — redis or memcached"
  type        = string
  default     = "redis"
  validation {
    condition     = contains(["redis", "memcached"], var.engine)
    error_message = "engine must be redis or memcached."
  }
}

variable "engine_version" {
  description = "Cache engine version"
  type        = string
  default     = "7.1"
}

variable "node_type" {
  description = "ElastiCache node type"
  type        = string
  default     = "cache.t3.medium"
}

variable "num_cache_nodes" {
  description = "Number of cache nodes (Memcached) or number of node groups (Redis cluster mode disabled = 1)"
  type        = number
  default     = 1
}

variable "num_cache_clusters" {
  description = "Number of Redis replica clusters"
  type        = number
  default     = 2
}

variable "subnet_group_name" {
  description = "ElastiCache subnet group name (created when subnet_ids is non-empty)"
  type        = string
  default     = null
}

variable "subnet_ids" {
  description = "Subnet IDs for the subnet group"
  type        = list(string)
  default     = []
}

variable "security_group_ids" {
  description = "Security group IDs"
  type        = list(string)
}

variable "automatic_failover_enabled" {
  description = "Enable Redis automatic failover (requires num_cache_clusters >= 2)"
  type        = bool
  default     = true
}

variable "multi_az_enabled" {
  description = "Enable Multi-AZ for the replication group"
  type        = bool
  default     = true
}

variable "at_rest_encryption_enabled" {
  description = "Enable at-rest encryption"
  type        = bool
  default     = true
}

variable "transit_encryption_enabled" {
  description = "Enable in-transit TLS encryption"
  type        = bool
  default     = true
}

variable "kms_key_id" {
  description = "KMS key ARN for at-rest encryption"
  type        = string
  default     = null
}

variable "auth_token" {
  description = "Redis AUTH token (required when transit_encryption_enabled = true)"
  type        = string
  default     = null
  sensitive   = true
}

variable "snapshot_retention_limit" {
  description = "Days to retain Redis snapshots (0 disables)"
  type        = number
  default     = 7
}

variable "snapshot_window" {
  description = "Daily snapshot window (UTC)"
  type        = string
  default     = "03:00-04:00"
}

variable "maintenance_window" {
  description = "Weekly maintenance window"
  type        = string
  default     = "sun:05:00-sun:06:00"
}

variable "parameters" {
  description = "Map of cache parameter names to values"
  type        = map(string)
  default     = {}
}

variable "tags" {
  description = "Resource tags to apply to all resources"
  type        = map(string)
  default     = {}
}
