I recently had some fun and games with vRA 8.2’s extensibility capabilities, particularly with PowerShell support for vRA actions. I wanted to see what I could break, so I tried to obtain the ‘userName’ of the requester from the metadata section using PowerShell. However, no matter what I did, the metadata always remained empty.
I then discovered that using the Flow type of action can be quite handy. This allows me to chain multiple actions together and pass output from one action to another by updating values. What I didn’t realize at first was that I could also add new properties to the payload with a value, use it in the next action, and then remove it so that there is no ‘secret data’ left over on the deployed resource properties.
Here is an example of a simple PowerShell action I wrote:
The $payload that is injected into the function contains all the information and properties as of the time of the subscribed event. I create a new object, copy all of the payload to it. I then pass the new payload, stored as $outputs to the Add-Member PowerShell function. I add a new property called ‘Testing’ and set a value on it of ‘Michael.’ Finally, I return the $outputs, sending this object as an output that will be used as the payload into the next action in the flow.
In the second action, I again take the $payload and make a new object and copy all of its properties and values. To prove that the previous action’s output contains the new ‘Testing’ property, I write out the value to the console [log]. Finally, I remove the property from my $outputs object and return it.
When the blueprint is requested following the action executions, you can clearly see our new property ‘Testing’ printed out to the screen. However, when we look at the properties of the deployed resource once deployment is complete, the property is not shown.
This demonstrates how we can add new properties to the payload and use them in subsequent actions without leaving any ‘secret data’ behind on the deployed resource properties. Additionally, this shows how we can chain multiple actions together using the Flow type of action and pass output from one action to another by updating values.
I hope that someone out there can tell me what I have done wrong! Please let me know if you have any answers on a postcard.