variable "env" {
  type        = string
  default     = "dev"
  description = "The environment name, e.g., dev, staging, prod"
}

variable "cloud_region" {
  type        = string
  description = "The AliCloud region to deploy in, e.g., cn-shanghai"
}

variable "logical_region_name" {
  type        = string
  description = "The TiDBCloud logical region name. Multiple logical regions can share one cloud region."
}

variable "zone_ids" {
  type        = list(string)
  description = "List of exactly 3 availability zone IDs for node vswitches"

  validation {
    condition     = length(var.zone_ids) == 3
    error_message = "You must specify exactly 3 zone IDs."
  }
}

variable "vpc_cidr" {
  type        = string
  default     = "10.0.0.0/16"
  description = "CIDR block for the VPC"

  validation {
    condition     = can(cidrhost(var.vpc_cidr, 0))
    error_message = "vpc_cidr must be a valid CIDR block."
  }
}

variable "service_cidr" {
  type        = string
  default     = "172.20.0.0/16"
  description = "CIDR block for Kubernetes service IPs"

  validation {
    condition     = can(cidrhost(var.service_cidr, 0))
    error_message = "service_cidr must be a valid CIDR block."
  }
}

variable "admin_ram_ids" {
  type        = list(string)
  default     = []
  description = "List of RAM role UIDs to grant cluster-admin permissions"
}

variable "public_access_cidrs" {
  type        = list(string)
  default     = []
  description = "Additional CIDRs that are allowed to access the API Server SLB"
}

# Worker node pool scaling
variable "worker_min_size" {
  type        = number
  default     = 1
  description = "Minimum number of nodes in the worker node pool"
}

variable "worker_max_size" {
  type        = number
  default     = 10
  description = "Maximum number of nodes in the worker node pool"
}

variable "worker_instance_type" {
  type        = string
  default     = "ecs.r8a.xlarge" # ecs.r8i.xlarge/ecs.r8a.xlarge/ecs.r7i.xlarge/ecs.r7a.xlarge
  description = "Instance type for the worker node pool (4C32G memory-optimised). ESS autoscaling only supports a single instance type per node pool."
}

variable "nat_bandwidth" {
  type        = number
  default     = 100
  description = "EIP bandwidth (Mbps) for the NAT gateway"
}

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