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 "secrets_overrides" {
  description = "Overrides for environment-specific ssm secrets"
  type        = map(any)
  default     = {}
}

variable "enable_autoscaling" {
  description = "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     = 2
}

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

variable "scale_in_cooldown" {
  description = "Cooldown period for scale in operations (in seconds)"
  type        = number
  default     = 300
}

variable "scale_out_cooldown" {
  description = "Cooldown period for scale out operations (in seconds)"
  type        = number
  default     = 300
}

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

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

variable "healthcheck_path" {
  description = "Path for container healthcheck"
  type        = string
  default     = ""
}

variable "tasks_iam_role_arn" {
  description = "ECS Task role"
  type        = string
}

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
}

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