Hello folks! I have been dealing with this problem for quite some time now and am hoping to be missing something really simple at this point!
Basically, when I use the JSON syntax of building the terraform files,I cannot get the disk portition to function correctly and the error given is quite odd. When I use the HLC2 format, it works like a charm!
I am not using one of the known providers but the libvirt one for creating VMs with KVM:
{
"data": [
{
"template_file": [
{
"user_data": [
{
"template": "$file(\"/home/terraform/config/cloud_init.cfg\")"
}
]
}
]
},
{
"template_file": [
{
"meta_data": [
{
"template": "file(\"/home/terraform/config/network_config.cfg\")"
}
]
}
]
}
],
"resource": [
{
"libvirt_volume": [
{
"vm-001": [
{
"format": "qcow2",
"name": "vm-001.qcow2",
"pool": "vm-storage",
"source": "/home/terraform/images/CentOS-7.qcow2"
}
]
}
]
},
{
"libvirt_cloudinit_disk": [
{
"cloudinit": [
{
"meta_data": "${data.template_file.meta_data.rendered}",
"name": "cloudinit.iso",
"pool": "vm-storage",
"user_data": "${data.template_file.user_data.rendered}"
}
]
}
]
},
{
"libvirt_domain": [
{
"vm-001": [
{
"autostart": "true",
"cloudinit": "${libvirt_cloudinit_disk.cloudinit.id}",
"memory": "2048",
"name": "vm-001",
"network_interface": [
{
"bridge": "br0"
}
],
"disk": {
[
{
"volume_id": "${libvirt_volume.vm-001.id}"
}
]
},
"running": "true",
"vcpu": "2"
}
]
}
]
}
]
}
This is my .tf.json file and the error given is:
Error: Incorrect attribute value type
on vm.tf.json line 69, in resource[2].libvirt_domain[0].vm-001[0]:
69: "disk": [
70: {
71: "volume_id": "${libvirt_volume.vm-001.id}"
72: }
73: ],
Inappropriate value for attribute "disk": element 0: attributes
"block_device", "file", "scsi", "url", and "wwn" are required.
If someone would give me a hand with this it would be greatly appreciated!