Skip to content

Instantly share code, notes, and snippets.

@gdsotirov
Created August 19, 2020 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdsotirov/c92c19b59bf3e7fcefbc86d61a2ee3a7 to your computer and use it in GitHub Desktop.
Save gdsotirov/c92c19b59bf3e7fcefbc86d61a2ee3a7 to your computer and use it in GitHub Desktop.
Check a number variable in Terraform to be a positive integer
# Check whether an input variable is a positive integer in Terraform
# Tested with version 0.13
variable "release" {
type = number
description = "Release number"
default = 0
validation {
condition = tonumber(var.release) == floor(var.release)
error_message = "Release should be an integer!"
}
validation {
condition = var.release >= 0
error_message = "Release should be a positive integer!"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment