Terraform

How would you enforce users that use your variables to provide values with certain constraints? For example, a number greater than 1

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

Using validation block

variable "some_var" {
  type = number

  validation {
    condition = var.some_var > 1
    error_message = "you have to specify a number greater than 1"
  }

}