variable "name" {
  description = "Name of the compute pool. Must be uppercase letters, digits, and underscores only."
  type        = string
  validation {
    condition     = var.name == upper(var.name) && can(regex("^[A-Z0-9_]+$", var.name))
    error_message = "Compute pool name must contain only uppercase letters, digits, and underscores."
  }
}

variable "instance_family" {
  description = "Identifies the type of machine to provision for the nodes in the compute pool"
  type        = string
  validation {
    condition = contains(
      [
        "CPU_X64_XS", "CPU_X64_S", "CPU_X64_M", "CPU_X64_SL", "CPU_X64_L",
        "HIGHMEM_X64_S", "HIGHMEM_X64_M", "HIGHMEM_X64_SL", "HIGHMEM_X64_L",
        "GPU_NV_S", "GPU_NV_M", "GPU_NV_L",
        "GPU_NV_XS", "GPU_NV_SM", "GPU_NV_2M", "GPU_NV_3M", "GPU_NV_SL",
        "GPU_GCP_NV_L4_1_24G", "GPU_GCP_NV_L4_4_24G", "GPU_GCP_NV_A100_8_40G",
      ],
      var.instance_family
    )
    error_message = "Instance family verification failed"
  }
}

variable "min_nodes" {
  description = "Minimum number of nodes for the compute pool"
  type        = number
  default     = 1
}

variable "max_nodes" {
  description = "Maximum number of nodes for the compute pool"
  type        = number
  default     = 1
}

variable "auto_resume" {
  description = "Automatically resume a compute pool when a service or job is submitted to it"
  default     = true
}

variable "auto_suspend_secs" {
  description = "Number of seconds of inactivity after which Snowflake automatically suspends the compute pool. Set to 0 to disable auto-suspend."
  type        = number
  default     = 3600
}

variable "comment" {
  description = "Compute pool description"
  type        = string
  default     = null
}

variable "for_application" {
  description = "Specifies the Snowflake Native App name this compute pool is associated with"
  type        = string
  default     = null
}

variable "timeouts" {
  description = "Timeout durations for compute pool operations (create, update, delete, read). Uses Go duration strings e.g. \"30m\", \"1h\"."
  type = object({
    create = optional(string, "1h")
    update = optional(string, "1h")
    delete = optional(string, "1h")
    read   = optional(string, "1h")
  })
  default = {}
}

variable "team" {
  type        = string
  description = "Team name compute pool belongs to."
  default     = ""
}

variable "team_tag_name" {
  default = "SNOWFLAKE_SETTINGS.TAGS.TEAM"
}
