That’s a long post title, right?! Well, a lot of moving parts for this one. 😉

Terraform is a powerful tool to achieve infrastructure-as-code. You can do many things, from configuring Cisco ACI to creating and maintaining a VMware Cloud on AWS and everything in between. There’s also a vSphere provider that allows you to deploy VMs from OVA templates. That’s where this story begins.

vRealize Network Insight Cloud has a platform where the data is stored and a collector, which does the collecting. This collector needs to be placed as close to the data source as possible. For VMware Cloud on AWS, that means placing the collector inside each SDDC that it’s monitoring.

A customer wanted to automate the deployment of the collectors using Terraform. So far, all automated deployments were done using a PowerShell script, so I was eager to give this a try. It turns out it’s quite simple. 

The vSphere Provider for Terraform has an option to deploy OVFs and fill their configuration parameters. William Lam has a great article from when that support was released with more information.

Using that OVF support, I translated the appliance settings we used in the PowerShell script to a Terraform config. The only challenge that I came across was that the vSphere provider doesn’t dare change OVF settings with the flag userConfigurable set to false

The vRNI collector only has 1 configurable setting during deployment, which is the shared secret (mostly because that’s too long to type into the console). Its configuration (network, passwords, etc.) is done in the console using the setup command. With PowerCLI (Import-VApp), you can still configure settings that have set userConfigurable to false. With the vSphere provider for Terraform, you can not.

Simple enough solution, though – I unzipped the collector OVA, changed the userConfigurable flags to true, and recreated the OVA. The Terraform config below is using that collector OVA; it downloads it from AWS S3.

Terraform config

Below is the entire terraform config file. It’s straightforward enough so I won’t comment on every line. Make sure you go through it and make modifications to the settings. Things like the vSphere credentials, appliance network settings, Proxy_Shared_Secret, etc. 

The appliance size is set to a medium collector with 4 vCPUs and 12GB of RAM. If you need a large collector, change the resources in line with the documentation.

If you’re not aware, the Proxy_Shared_Secret is generated in vRNI and contains the information needed for the collector to pair with vRNI. This is the same for both vRNI on-premises and vRNI Cloud. 

Terraform Apply

It’s pretty interesting to see this deployment (or any Terraform-backed deployment 😉 ).

When running this for the first time, download the vSphere provider using:

Then deploy!

When this is done, the appliance will be running and the collector will be initializing. Give it between 5 to 10 minutes and you’ll see this lovely message in vRealize Network Insight Cloud:

vRNI Cloud after Terraform apply

Share the wealth!