In case anyone comes here looking for an example (as it took me days of banging head against the proverbial wall to get this working with templatefile function):
cloud_config.tftpl
#cloud-config
hostname: ${hostname}
user: ops-user
ssh_authorized_keys:
- OPS_USER_SSH_KEY
manage_etc_hosts: true
fqdn: ${hostname}.${domain}
package_upgrade: true
users:
- default
cloud_network_config.tftpl
#cloud-config
version: 1
config:
- type: physical
name: eth0
subnets:
- type: static
address: '${ip}'
netmask: '255.255.255.0'
gateway: '10.1.50.1'
resource "xenorchestra_vm" "unc-lab" {
......
cloud_config = templatefile("cloud_config.tftpl", {
hostname = "unc-lab"
domain = "morris.lan"
})
cloud_network_config = templatefile("cloud_network_config.tftpl", {
ip = "10.1.55.34"
})
.......
Thanks @ddelnano for your help!