Created
August 19, 2020 13:30
-
-
Save gdsotirov/c92c19b59bf3e7fcefbc86d61a2ee3a7 to your computer and use it in GitHub Desktop.
Check a number variable in Terraform to be a positive integer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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