I'd like to present a single HCL2 Packer template to build some systems but I need to vary the number of "storage {}" sections, only provisioning a second disk if the "disk_size" setting for the second one is "> 0".
Does HCL2 have any "if" clauses, or if not is there a way using HCL2 to do this, or do I need to re-write my calling script to modify the HCL2 file before sending it to Packer?
Example:
I define the variables "root_disk_size" and "additional_disk_size", and the builder section has two "storage {}" sections:
storage {
disk_size = var.root_disk_size
}
storage {
disk_size = var.additional_disk_size
}
Is it possible to wrap the second section in a test something like "if var.additional_disk_size > 0"?