Terraform vSphere Provider – Error while creating vApp properties
Tags: terraform, vmware, ovf
Published: 2021-08-02 15:59:27

---
title: Terraform vSphere Provider – Error while creating vApp properties
published: true
date: 2021-07-30 21:58:54 UTC
tags: Terraform,VMware,OVF
canonical_url: https://veducate.co.uk/terraform-vsphere-vapp-properties/?utm_source=rss&utm_medium=rss&utm_campaign=terraform-vsphere-vapp-properties
---

###### The Issue

When using Terraform to deploy a virtual machine OVA using Terraform, I kept hitting the below error:

```
Error: error while creating vapp properties config unsupported vApp properties in vapp.properties: [vm.vmname vami.gateway.DMS_agent_VA vami.netmask0.DMS_Agent_VA vami.DNS.DMS_Agent_VA vami.searchpath.DMS_Agent_VA vami.ip0.DMS_Agent_VA vami.domain.DMS_Agent_VA]

  on Agent_appliance/main.tf line 20, in resource "vsphere_virtual_machine" "vm":
  20: resource "vsphere_virtual_machine" "vm"
```

Pretty simple right? In my Terraform file I was trying to use OVF Properties that were not valid. Getting the debug/trace logs from terraform also just showed the same error output.

However running ovftool, confirmed my properties were correct. (shortened output example).

```
ClassId: vami
  Key: searchpath
  InstanceId DMS_Agent_VA
  Category: Networking Properties
  Label: Domain Search Path
  Type: string
  Description: The domain search path (comma or space separated domain names) 
               for this VM. Leave blank if DHCP is desired.
```

But also in the vCenter UI, looking at the vApp Properties of a the OVA once deployed, again I could validate the the properties I was using were correct.

[![vCenter - Virtual Machine vApp Options Properties](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/07/vCenter-Virtual-Machine-vApp-Options-Properties.jpg?resize=604%2C253&ssl=1)](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/07/vCenter-Virtual-Machine-vApp-Options-Properties.jpg?ssl=1)

Finally an example of the vSphere\_virtual\_machine resource I was trying to deploy that was causing me issues:

```
resource "vsphere\_virtual\_machine" "vm" {
  name = "${var.agent\_vm\_name}"
  resource_pool_id = "${var.resource\_pool\_id}"
  datastore_id = "${data.vsphere\_datastore.datastore.id}"
  folder = "${var.folder}"
  wait_for_guest_net_timeout = 0
  wait_for_guest_ip_timeout = 0
  datacenter_id = "${data.vsphere\_datacenter.dc.id}"
  host_system_id = "${data.vsphere\_host.host.id}"

  dynamic "ovf\_deploy" {
  for_each = "${var.agent\_local\_ovf\_path}" != "" || "${var.agent\_remote\_ovf\_path}" != "" ? [0] : []
  content {
  // Path to local or remote ovf/ova file
  local_ovf_path = "${var.agent\_local\_ovf\_path}" != "" ? "${var.agent\_local\_ovf\_path}" : null
  remote_ovf_url = "${var.agent\_remote\_ovf\_path}" != "" ? "${var.agent\_remote\_ovf\_path}" : null
   disk_provisioning = "thin"
   ovf_network_map = {
        "Control Plane Network" = data.vsphere\_network.network.id
    }
   }
  }

  vapp {
    properties = {
      "vm.vmname" = "${var.agent\_vm\_name}",
      "varoot_password" = "${var.varoot\_password}",
      "vaadmin_password" = "${var.va\_admin\_password}",
      "guestinfo.cis.appliance.net.ntp" = "${var.ntp}",
      "vami.gateway.DMS_agent_VA" = "${var.controlplanenetworkgateway}",
      "vami.DNS.DMS_Agent_VA" = "${var.dns}",
      "vami.domain.DMS_Agent_VA" = "${var.domain}",
      "vami.searchpath.DMS_Agent_VA" = "${var.searchpath}",
      "vami.ip0.DMS_Agent_VA" = "${var.agentip0}",
      "vami.netmask0.DMS_Agent_VA" = "${var.agentip0netmask}"
    }
  }
}
```

###### The Cause

Yep, you guessed it, there was something wrong with the properties I was trying to configure.

###### The Fix

After testing a number of ways to validate the OVF Properties expected, I came across a blog from William Lam, where he produced a PowerShell script that calls the vSphere API for the OVF Properties of a given VM.

- [https://williamlam.com/2017/10/updating-ovf-properties-for-a-vm-using-vsphere-api-and-powercli.html](https://williamlam.com/2017/10/updating-ovf-properties-for-a-vm-using-vsphere-api-and-powercli.html)

Running his Powershell script against a deployed copy of the OVA, I noticed the return values were not the same as in the vCenter UI.

So I changed the Terraform files to use the values I seen below, ran again and success!

[![Get-VMOvFProperty output](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/07/Get-VMOvFProperty-output.jpg?resize=604%2C269&ssl=1)](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/07/Get-VMOvFProperty-output.jpg?ssl=1)

I’ve dropped a note to the team behind the provider about this to see if its the expected behaviour.

I also logged this issue and closed it in [GitHub here](https://github.com/hashicorp/terraform-provider-vsphere/issues/1455).

And finally, if you want to check out the Terraform module I was building to Deploy Data Management for Tanzu, you can [find it here](https://github.com/saintdle/Terraform/tree/master/Deploy-Data-Management-for-VMware-Tanzu).

The Cause

Regards

[Follow @Saintdle](https://twitter.com/saintdle)<script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

[Dean Lewis](https://uk.linkedin.com/in/saintdle?trk=profile-badge)

 

The post [Terraform vSphere Provider – Error while creating vApp properties](https://veducate.co.uk/terraform-vsphere-vapp-properties/) appeared first on [vEducate.co.uk](https://veducate.co.uk).