variable "aws_account" {
  description = "Target account where this service will be deployed to"
  type        = string
}

variable "env" {
  description = "Environment name"
  type        = string
}

variable "humand_vpc_id" {
  description = "Humand VPC"
  type        = string
}

variable "cluster_name" {
  description = "Service cluster name"
  type        = string
}

variable "ingress_lb_tg" {
  description = "Target group that this service will be attached to"
  type        = string
}

variable "cidr_block" {
  description = "The CIDR block that specifies the range of IP addresses for the network"
  type        = string
}

variable "docker_image" {
  description = "Docker image to deploy"
  type        = string


  validation {
    condition     = can(regex(".+/[^/]+:([a-f0-9]{7}|placeholder)$", var.docker_image))
    error_message = "El string debe tener el formato 'dominio/repositorio:shortsha' o 'dominio/repositorio:placeholder'"
  }
}

variable "service" {
  description = "Name of this service"
  type        = string
}

variable "environment_overrides" {
  description = "Overrides for environment-specific settings"
  type        = map(any)
  default     = {}
}

variable "node_type" {
  description = "Type of deployable"
  type        = string

  validation {
    condition     = contains(["worker", "event-handler", "cdc"], var.node_type)
    error_message = "The node type must be one of: worker, event-handler, cdc"
  }
}

variable "secrets_overrides" {
  description = "Overrides for environment-specific ssm secrets"
  type        = map(any)
  default     = {}
}

variable "cpu" {
  description = "Cpu of the ECS task"
  type        = number
  default     = 1024
}

variable "memory" {
  description = "Memory of the ECS task"
  type        = number
  default     = 2048
}

variable "fargate_weight" {
  description = "Weight of non-spot Fargate tasks in the fleet"
  type        = number
}

variable "fargate_spot_weight" {
  description = "Weight of spot Fargate tasks in the fleet"
  type        = number
}

# Autoscaling variables
variable "enable_autoscaling" {
  description = "Whether to enable autoscaling for the ECS service"
  type        = bool
  default     = true
}

variable "autoscaling_min_capacity" {
  description = "Minimum number of tasks for autoscaling"
  type        = number
  default     = 1
}

variable "autoscaling_max_capacity" {
  description = "Maximum number of tasks for autoscaling"
  type        = number
  default     = 5
}

variable "health_check_path" {
  description = "Path to check the health of the ECS task"
  type        = string
}

variable "task_policies" {
  description = "Policies to attach to the ECS task"
  type        = map(string)
  default     = {}
}

variable "autoscaling_type" {
  description = "Type of autoscaling: 'cpu' or 'sqs'"
  type        = string
  default     = "cpu"

  validation {
    condition     = contains(["cpu", "sqs"], var.autoscaling_type)
    error_message = "autoscaling_type must be either 'cpu' or 'sqs'"
  }
}

variable "cpu_target_utilization_percent" {
  description = "Target CPU utilization percentage for CPU-based autoscaling"
  type        = number
  default     = 30
}

variable "scale_in_cooldown" {
  description = "Cooldown period in seconds after scaling in"
  type        = number
  default     = 300
}

variable "scale_out_cooldown" {
  description = "Cooldown period in seconds after scaling out"
  type        = number
  default     = 60
}

variable "sqs_queue_name" {
  description = "Name of the SQS queue to monitor for SQS-based autoscaling"
  type        = string
  default     = ""
}

variable "sqs_messages_per_task_target" {
  description = "Target number of messages per task (for SQS autoscaling)"
  type        = number
  default     = 10
}
