VMware Cloud Community
roniyako
Contributor
Contributor
Jump to solution

Deploy a Server in AWS with Different AMI ID

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.

Reply
0 Kudos
1 Solution

Accepted Solutions
rmav01
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
5 Replies
rmav01
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
roniyako
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
roniyako
Contributor
Contributor
Jump to solution

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?

Reply
0 Kudos
roniyako
Contributor
Contributor
Jump to solution

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.

Reply
0 Kudos
lukez1985
Contributor
Contributor
Jump to solution

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.

Reply
0 Kudos