I am getting error if I am using null default value
variable "data" {
type = object({
foo = string
})
}
variable "optional_data" {
type = object({
custom_image_name = string
custom_image_resource_group_name = string
})
default = {
custom_image_name = null
custom_image_resource_group_name = null
}
}
locals {
merged_data = "${merge(var.data, var.optional_data)}"
}
data "azurerm_image" "image" {
name = "${local.merged_data.custom_image_name}"
resource_group_name = "${local.merged_data.custom_image_resource_group_name}"
count = "${local.merged_data.custom_image_name != "" && local.merged_data.custom_image_resource_group_name != "" ? 1 : 0 }"
}
will result in
Error: "resource_group_name": required field is not set
If I change default value of custom_image_resource_group_name
variable "optional_data" {
type = object({
custom_image_name = string
custom_image_resource_group_name = string
})
default = {
custom_image_name = null
custom_image_resource_group_name = ""
}
}
it will work…
Is it intended ?
How can I use null in this use case? Is it even possible?
Thanks