How to define AWS instance type in Service Dialog

I have a use-case where the user would pick either a dev, test, or prod environment that the service belongs in, and then I will want CloudForms to provision a ‘m2.micro’ for a dev environment, but ‘m1.small’ for test and prod environments.

Is it possible to change the type of instance to be provisioned in AWS based on what option is chosen in a Service Dialog?

Yes, you can do that in amazon_CustomizeRequest by using a case statement based on user dialog selection. You will set flavor in option object. You will need to set flavor with id and not name, for this you can check in flavors table.
If you need more details or code example, please feel free to ask in this forum.

1 Like

I presented a session on exactly this usecase, you can find the materials and slides here :

Whilst CustomizeRequest can service your usecase, its code. The idea behind service item selection is to do the opposite, by allowing you to construct services with many items as in your case, two types of flavours then only reliving one based on selection.

1 Like

Thanks @loicavenel, I just wanted to add a comment that your suggestion works for me.

I started by cloning the method ‘/Cloud/VM/Provisioning/StateMachines/Methods/amazon_CustomizeRequest’ into my own domain.

Then I added the following code:

prov.set_option(:instance_type, [65000000000002, "t2.small: T2.Small"])

And the VM was provisioned with the desired type.