vRA 7.4 – AWS User Data

AWS user data is the topic of today’s post, I was very vocal about the functionality lost going from vCAC 6 and AppD to 7.x. This functionality has slowly been re introduced over the releases, AWS user data is one of these… sort of it was an add on that was available.

So how do we use this new-old feature?
I am assuming you may have found this page due to the lack of information in the documentation on how to actually take advantage of this feature, it is very light on, but good news it is almost exactly the same as I remember it.

1) First you need to apply the “Amazon.Extensions.UserData property”. This can be selected to show on the form. But in general this value would be filled in programmatically or Hard set in the value.

2) Any values that might be dynamic you need to pass in using “Amazon.CustomProperty.insertnamehere” Again this value can be listed on the form, or set within the blueprint.

So now we have the properties how can we use them? This is the part that is not very clear. We have really 3 options.

Option 1
During the request of the machine I can paste my script directly into the text box (only if the property has been configured as a “text area” as shown in the below image.

#!/bin/bash
yum install httpd -y
service httpd start
chkconfig httpd on

When this is submitted. I use cloud client to get the submission data and we see:
"values" : {
"empty" : false,
"entries" : [ {
"key" : "Amazon.Extensions.UserData",
"value" : {
"type" : "string",
"value" : "#!/bin/bash\nyum install httpd -y\nservice httpd start\nchkconfig httpd on"
}

This Option is fine, if your actually pasting the script you want in at request time via the UI. This is not what most people want we need to inject it of have it directly in the blueprint, to do this we need to have single line scripts. that leads me to option 2.

Option 2
From the previous option and the value it inserted, I thought I would be smart and submit this directly at request time. but vRA will then place an additional “\”, too smart for its own good.
"values" : {
"empty" : false,
"entries" : [ {
"key" : "Amazon.Extensions.UserData",
"value" : {
"type" : "string",
"value" : "#!/bin/bash\\nyum install httpd -y\\nservice httpd start\\nchkconfig httpd on"
}

This is why there are place holders:
{CR} = \r
{LF} = \n
{CRLF} = \r\n
{TAB} = \t

If we want to use that custom property we had in the above image “Amazon.CustomProperty.myname” we use the place holder in the script {Amazon.CustomProperty.myname}
The script I submit would look like this:
#!/bin/bash{LF}yum install httpd -y{LF}service httpd start{LF}chkconfig httpd on{LF}echo "hello{CRLF}{Amazon.CustomProperty.myname}{TAB}sup"

I log into the machine after it is built and check to see the script created and executed, you can see all the placeholders worked perfectly

#!/bin/bash
yum install httpd -y
service httpd start
chkconfig httpd on
echo "hello

Awesome all working like a treat, checked the logs and it installed and works as expected.

Option 3

We can also submit config data in the form of a JSON string, this config data would be consumed by scripts etc. A sample config is something like this.

{ "Name": "{Amazon.CustomProperty.myname}", "Alias": ["Chuck", "Norris","hey you" ]}
After provisioning the machine I can then see the user data within the AWS portal.

That’s it AWS user data working like a treat.

Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Anti SPAM BOT Question * Time limit is exhausted. Please reload CAPTCHA.