Using cloudinit_config data as variable for virtual machine module.
Hello,
I’m trying to create a module that mainly contains a vsphere_virtual_machine
resource inside which I’m defining the following vapp parameters:
vapp {
properties = {
user-data = base64encode(data.template_cloudinit_config.prometheus.rendered)
"hostname" = var.hostname
}
}
The cloudinit data is normally (without modules) defined in the same terraform state as the virtual machine, but if I want to create the module, things get a little complicated and I’m not sure if I can insert the whole thing as such, something to the effect of:
(inside the module definition):
vapp {
properties = {
user-data = base64encode(var.cloudinit_config)
"hostname" = var.hostname
}
}
(when calling the module):
module "virtual_machine" {
source = "../modules/virtual_machine"
cloudinit_config = data.template_cloudinit_config.prometheus.rendered
[...]
}
Would that make sense? How would you normally go about solving this problem?