Skip to main content
max(numbers...) returns the highest value from the given numbers.

Signature

max(numbers... number) number
At least one argument is required.

Example

Cap the concurrency to the number of available CPU cores, but never exceed a configured maximum:
variable "max_workers" {
  description = "Maximum number of parallel test workers"
  type        = number
  default     = 8
}

variable "min_workers" {
  description = "Minimum number of parallel test workers"
  type        = number
  default     = 2
}

computed "workers" {
  description = "Effective worker count"
  expression  = max(var.min_workers, var.max_workers)
}

task "test" {
  description = "Run the test suite with the computed worker count"
  commands    = ["go test -parallel ${computed.workers} ./..."]
}

Notes

  • All arguments must be numbers.
  • To find the smallest value, use min.