I had a similar requirement to this in the past. To accomplish this, I used the event broker to parse in a custom input (customer selected AMI) via the input payload, then swapped out the __amazon.Image.Id property by using the following method prior to the machine provisioning:
This allowed me to seed a single blueprint with a generic AMI, and swap to the real thing to whatever I wanted as long as the underlying compute resource could see this new value.
Thanks for the reply, i will test this out, how did you deal with importing the image, currently AWS resources get imported once a day in our VRA, so if i create a image is there a way to force the image to come in or do we have to increase the frequency of this import for all resources.?
Tested your suggestion with the below code
ami1 = payload.machine.properties.get("__amazon.Image.ID");
System.debug("ami = " + ami1);
Below is the Logs
[2018-02-10 23:57:59.163] [D] ami = ami-00061c63
[2018-02-10 23:57:59.165] [D] VM ID : 93eccf46-6e24-425e-b581-da7b04408d8f
The issue i've ran into is my pre machine provisioning workflow, the workflow has the payload as a input, so when i do the scripting in my scriptable task, the payload variable is classified as a IN and not a OUT, so the update is not taking effect.
in my payload variable the ami is still the old one.
any ideas what i can do?
Okay it's working now, we have a properties file that we are populating machine data with. tried it again this morning and it seems i can update the AMI.
pretty simple one line of code, thanks for the help.
Just need to figure out the best way to import the AMI now.
Interesting you have this working. I have tried setting "__amazon.Image.ID" during a PRE MachineBuilding & Requested event subscription and it doesn't change the image used. Same with trying to set the instance type.