Given this
variable "with_optional_attribute" {
type = object({
a = string # a required attribute
b = optional(string) # an optional attribute
c = optional(number, 127) # an optional attribute with a default value
})
default = null
}
Should I be able to rely on the default value of null being set for the variable?
When I have this
output "test" {
value = var.with_optional_attribute == null ? "default" : "set"
}
I get the following error:
╷
│ Error: Invalid value for input variable
│
│ on variables.tf line 11:
│ 11: variable "with_optional_attribute" {
│
│ The given value is not suitable for var.with_optional_attribute declared at variables.tf:11,1-35: attribute "a" is required.
╵
I can explicitly set the variable to null and it works so is optionality now completely defined by the object attribute definitions for object variables now?