Azure and Amazon VM post-provisioning



Pls. can you give me a right direction how to do a Amazon / Azure post provisioning. Concretely I am looking for a way how to assign a tag to an Amazon/Azure VM during provisioning process automatically.


Auto tagging VM upon creation

@gmccullough any guidance here?


Hi @Karel,

There are post-provisioning methods are defined in automate under: /ManageIQ/Cloud/VM/Provisioning/StateMachines/Methods.

You can copy the methods to a writable domain and modify as needed.

For example, copy the amazon_PostProvision method and update it to use the tag_assign method to apply the new tags.

You can see an example of how to use the tag_assign method from automate here:


I would reccomend taking a look at the Cloud_Essentials domain.

it has some great methods, for example “ec2_synchronize_tags”

you can splice that into the “post” steps in /Service/Provisioning/StateMachines/Methods/CatalogItemInitialization

It worked well for me. makes things easy. “some one wrote that already” :slight_smile:

there are some tings you might want to fiddle with, for example tags are all lower case.



Many thanks for your hints.

But I still can’t set it up. I think that a problem is the Catalog Entry point that use.
My Amazon and Azure Catalog Items are based on orchestration templates and I use this Provisioning Entry Point /Cloud/Orchestration/Provisioning/StateMachines/Provision/CatalogItemInitization. So I am not sure where I should add the tag instance.



The CatalogItemInitization instance you reference contains a post-provision step that calls /Cloud/Orchestration/Provisioning/StateMachines/Methods/PostProvision.

That method should look something like this:

# Description: This method examines the orchestration stack provisioned
def dump_stack_outputs(stack)
  $evm.log("info", "Outputs from stack #{}")
  stack.outputs.each do |output|
    $evm.log("info", "Key #{output.key}, value #{output.value}")

$evm.log("info", "Starting Orchestration Post-Provisioning")

task = $evm.root["service_template_provision_task"]
service = task.destination
stack = service.orchestration_stack


# You can add logic to process the stack object in VMDB
# For example, dump all outputs from the stack
# dump_stack_outputs(stack)

The service object has a method vms that will give you access to the VMs created for that service. You can add your tagging logic here or use one of the empty post states in the state-machine to add a reference to your own method.


Thanks for hint. I have added the code below to PostProvisioning.
All works without an error but the tags are not assigned. Is there any other method for VM tag assignment?

dialog_options = task.dialog_options
tagenv = dialog_options[‘dialog_tag_0_environment’]
tagregion = dialog_options[‘dialog_tag_0_region’]
$evm.log(:info, “Postprovisioning VM tags #{tagenv} #{tagregion}”)
$evm.log(:info, “vmdb_object_type => <#{$evm.root[‘vmdb_object_type’]}>”)

$evm.log(:info, “Postprovisioning check Service: #{} id: #{} guid: #{service.guid} vms: #{service.vms.count}”)
service.vms.each do |vm|
$evm.log(:info, “Postprovisioning VM check #{}”)

Assign Tag



The tag_assign method is expecting the tag catalog name not the description.

In this case it is just using the lower cased value:


The names are visible under Configuration -> Region settings.

If that does not work you should verify that you are passing the name for the tag as well.


I overlooked that. It works well now.

Thanks for help,