mirror of
https://github.com/hashicorp/terraform.git
synced 2026-03-22 02:20:07 -04:00
The current behavior of module input variables is to allow users to override a default by assigning `null`, which works contrary to the behavior of resource attributes, and prevents explicitly accepting a default when the input must be defined in the configuration. Add a new variable attribute called `nullable` will allow explicitly defining when a variable can be set to null or not. The current default behavior is that of `nullable=true`. Setting `nullable=false` in a variable block indicates that the variable value can never be null. This either requires a non-null input value, or a non-null default value. In the case of the latter, we also opt-in to the new behavior of a `null` input value taking the default rather than overriding it. In a future language edition where we make `nullable=false` the default, setting `nullable=true` will allow the legacy behavior of `null` overriding a default value. The only future configuration in which this would be required even if the legacy behavior were not desired is when setting an optional+nullable value. In that case `default=null` would also be needed and we could therefor imply `nullable=true` without requiring it in the configuration.
44 lines
530 B
HCL
44 lines
530 B
HCL
|
|
variable "foo" {
|
|
}
|
|
|
|
variable "bar" {
|
|
default = "hello"
|
|
}
|
|
|
|
variable "baz" {
|
|
type = list
|
|
}
|
|
|
|
variable "bar-baz" {
|
|
default = []
|
|
type = list(string)
|
|
}
|
|
|
|
variable "cheeze_pizza" {
|
|
description = "Nothing special"
|
|
}
|
|
|
|
variable "π" {
|
|
default = 3.14159265359
|
|
}
|
|
|
|
variable "sensitive_value" {
|
|
default = {
|
|
"a" = 1,
|
|
"b" = 2
|
|
}
|
|
sensitive = true
|
|
}
|
|
|
|
variable "nullable" {
|
|
type = string
|
|
nullable = true
|
|
default = "ok"
|
|
}
|
|
|
|
variable "nullable_default_null" {
|
|
type = map(string)
|
|
nullable = true
|
|
default = null
|
|
}
|