Use custom property value in cloud template – vRA 8.x/Cloud

Use Case

The customer I am working with had a custom property defined at the project level. They wanted to use the value of this custom property in the blueprint as a VC folder name. [folderName propeerty]

Custom Property on project

Solution

I have a custom property named “businessUnit” defined on my vRA project. To consume this property in the cloud template (blueprint), I need to define a property with the same name i.e. “businessUnit” on my vsphere machine properties. If you use property with the same name as the property defined on the project, the value gets overwritten at the time of build. Below is my Cloud Template with the property name “businessUnit” and a temp value.

 Cloud_vSphere_Machine_1:
    type: Cloud.vSphere.Machine
    properties:
      image: centos 7
      cpuCount: 1
      totalMemoryMB: 1024
      folderName: '${"CloudVMs/" + self.businessUnit}'
      businessUnit: temp
      networks:
        - network: '${resource.Cloud_vSphere_Network_1.id}'
      # conditionally attach between 0 and 5 disks to the machine
      attachedDisks: '${map_to_object(resource.Disk1[*].id + resource.Disk2[*].id + resource.Disk3[*].id + resource.Disk4[*].id + resource.Disk5[*].id, "source")}'

I can now use this property with “self.<PROPERTY NAME>” in my folderName property or any other field where I need to replace the values.

Deploy the VM and verify the businessUnit property has been overwritten by the value from project property.

Folder Name property updated

The VM has been deployed in the required folder in VC.

VM Deployed in VC Folder

Conclusion

We can use this process to replace any custom property value in our cloud template.

Author: Barjinder Singh

Leave a Reply