vRA 8.1 – add multiple disks to vm via blueprint – array iteration issue with count.index

This post was originally published on this site

I am having an issue with adding multiple disks do a vm in a blueprint. What I want to achieve is, that a user can add mutliple disks of various sizes, when requesting a new vsphere vm. I am almost there, however all of the disks added have the same size. I suspect the issue lies in the iteration of the disk configuration, whis is input as an array. Here are the relevant code snippets.


Disk configuration as input:

formatVersion: 1
    type: array
    title: Add disk
    description: Add new disks
    minItems: 0
    maxItems: 12
      type: object
          type: integer
          title: Size in GB
          maxSize: 2048
          minSize: 1


Disk resource:

    type: Cloud.vSphere.Disk
      count: '${length(input.disks)}'
      capacityGb: '${input.disks[count.index].size}'


VM resource:

    type: Cloud.vSphere.Machine
      attachedDisks: '${map_to_object(resource.Cloud_vSphere_Disk_1[*].id, "source")}'


When a vm is deployed, the user can add an array of disks sizes. The number of disks added to the vm is correct as a result, but the size of all of them is equal to the size of the first disk added, example: user adds 3 disks in sizes 1GB, 2GB, 3GB. The resulting vm has the boot disk and 3 additional disks, all of size 1GB.


The blueprint documentation sadly only provides information about creating a new array, not iterating over value of an existing one. In most examples only the first element of an array is loaded.

I assume the issue is in Cloud_vSphere_Disk_1, where the size is improperly read from the array by index.count.


Could anyone give me a tip on how to resolve the issue?


edit: a word

edit2: added count.index to title

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.