concept
Declare typed input variables
A variable block declares a module input. Type, default, nullable and validation define its interface. Sensitive display redaction differs from ephemeral persistence restrictions.
Formal Syntax & Structure
terraform syntaxterraform
Declare typed input variablesWorking Example
Example Snippetterraform
variable "replicas" { description = "Number of simulated service replicas." type = number default = 2 nullable = false
validation { condition = var.replicas >= 1 && var.replicas <= 8 && floor(var.replicas) == var.replicas error_message = "Choose a whole number from 1 through 8." }}
output "requested_replicas" { value = var.replicas}