Highlighted
Contributor
Contributor

Deploy a Server in AWS with Different AMI ID

Jump to solution

Hi,

I want to allow users to deploy a windows server in VRA based off an AMI they have created. When creating blueprints you have to specify an AMI ID and that stays constant, i was told there was a way through the cloud client to update the blueprint AMI, but the issue with this would be it would only really work if i had one user using the blueprint. I need multiple users using it, so what would the best way to achieve this be?

Goal: Have the ability to deploy a blueprint based on various images from AWS the user selects.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Enthusiast
Enthusiast

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:

System.getModule("com.vmware.library.vcac").addUpdatePropertyFromVirtualMachineEntity(...)

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.

View solution in original post

0 Kudos
5 Replies
Highlighted
Enthusiast
Enthusiast

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:

System.getModule("com.vmware.library.vcac").addUpdatePropertyFromVirtualMachineEntity(...)

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.

View solution in original post

0 Kudos
Highlighted
Contributor
Contributor

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.?

0 Kudos
Highlighted
Contributor
Contributor

Tested your suggestion with the below code

payload.machine.properties.put("__amazon.Image.ID","ami-00061c63");

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.

__amazon.Image.ID=ami-a9639acb,

any ideas what i can do?

0 Kudos
Highlighted
Contributor
Contributor

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.

virtualMachineAddOrUpdateProperties.put("__amazon.Image.ID","ami-00061c63");

Just need to figure out the best way to import the AMI now.

0 Kudos
Highlighted
Contributor
Contributor

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.

0 Kudos