Prerequisites

  • Cloud Administrator role.

Procedure

  1. Create a new action with the following parameters.

    Parameter

    Description

    Action Name

    ABX action name, preferably with 'TagVM' as a prefix or suffix.

    Project

    Project to test the ABX action against.

    Action Template

    Custom Script

    Runtime

    Python

    Script Source

    Write Script

  2. Enter the following script code:
    import json
    
    def handler(context, inputs):
    	print('Action started.')
    
    	tag = '<machine name>'
    	if 'Application" in vmName:
    		tag = 'Application Ter'
    	elif'DB' in vmName:
    		tag= 'DB Tier'
    
    	tags[tag]='<machine name>'
    
    	print('Tag VM action! tag: "{}".!format(tag))
    	print('Action finished!')
    	return {'tags':tags}
  3. Enter Handler as the Entrypoint.
  4. Add the following inputs for testing the ABX action.

    Input Name

    Value

    resourceNames

    ["DB_VM"]

    tags

    0

    target

    World

  5. Click Save to save your action.
  6. Click the settings icon and select a project with a lambda account to test your action against.

  7. Click Test to test your ABX action.
  8. Open the Test Console details to verify that the test was successful.

  9. Create a New Subscription.
  10. Enter the following subscription details.

    Detail

    Setting

    Event Topic

    Select an event topic related to the tagging phase of the VM. For example, Compute Allocation.

    Note:

    Tags must be part of the subscription schema.

    Blocking

    Make the subscription blocking for 1 min, in order to the tagging task to complete.

    Runnable Item Type

    Choose an ABX runnable type.

    Runnable id

    Select your custom ABX action.

  11. Click Create to save your custom ABX subscription.