Custom Node

The custom node is a particularly unique node that lets you add custom logic or configuration into the workflow, directly in a NodeJS v10 sandbox. Adding custom code enables you to add or remove qualities from input data.

To add a Custom node, click on the ‘+’ and select Custom. It can be added anywhere in the workflow where you need customization. Click on the node and select ‘edit’ to open the parameter options for the nodes.

‘Select a resource’ - You can choose from the dropdown the output of a particular node that you wish to customize or refer to. For example, if you’ve used an ‘HTTP node’ and called a data file from a certain repository, and you want to refer to that data in the custom node, you’ll select the output of the HTTP Node’ in this dropdown.

Like mentioned before, every resource, resource addon, and every other node has a unique ID that can be referenced in any other node. You can find the ID’s shown at the top of every node, below the ‘Node Name’. Wherever you’re required to reference the resource, you’ll see a dropdown with all the options listed below, and you can simply choose the relevant one.

‘Select a predefined logic’ - We’ve developed a few predefined custom logics, like the lambda cost predictor and detector, tags-info-format, etc, but you can enter almost any logic through this node. In order to add your custom logic, select “custom” in this dropdown.

For example, if you are migrating instances from one AZ to another, the custom logic can be used to define which instances need to be migrated, and across which AZs they must move; so the filter will pick out the correct instances.

The following should be noted while writing a custom function:

  • A context object is available in the custom function which contains a collection which is the output of the previous node (input to this node) and the selected region in the action or resource node previous to this node.

  • You could transform the data in whatever way you want. Please note that the collection object is read-only. Any transformations should be on a copy of it. Finally,

  • Call exit with (null, result). If there is an error, you could pass the error as the first parameter to the exit function and the second parameter should be null.

When using the Custom Logic, the first and last lines of the function cannot be edited