I’m using the ignition provider with Terraform v0.12
I have a data block that has the following;
data "ignition_config" "ign" {
for_each = var.hostnames_ip_addresses
append {
source = var.ignition_file_url
}
systemd = [
"${data.ignition_systemd_unit.restart[each.key].rendered}",
]
files = [
data.ignition_file.hostname[each.key].rendered,
data.ignition_file.static_ip[each.key].rendered,
]
}
This works as expected, as long as var.ignition_file_url
is not null, and contains a valid url string.
However, there are situations where I validly expect var.ignition_file_url
to be null.
The problem is - right now, the ignition provider crashes Terraform if a null source is passed to append.
Soooo, I’d like to figure out how to conditionally use append.
For example, I’d like to test if var.ignition_file_url
is not null, and then include the append.
Like this;
if (var.ignition_file_url != null) {
append {
source = var.ignition_file_url
}
}
I know from earlier responses to similar questions here, that I must use a conditional expression, rather than an imperative “if”.
How do I do this with a conditional expression?