2.2 Kaholo Pipeline with AWS

The Kaholo Designer allows you to create customized workflows by dragging and dropping multiple actions from the Integrations panel into the Design layer. Then, you only need to connect the cubes accordingly to start building the structure that you want.

In this example, we will start by creating a new AWS EC2 instance. Then, we will add a Slack notification that will let us know whether the operation was successful or not on the EC2 server.

 

  1. Click on the Actions icon in the left side panel. The panel will expand and show all the available plugins.
  2. Select the Amazon EC2 plugin and drag and drop it into the Design layer. This will be the first action to be executed within your pipeline.
  3. Select the Slack plugin and drag and drop it into the Design layer. Connect everything like on picture above

 

Now that we have designed an automation process, we can start configuring its actions and their methods. Once you have defined the order of steps to be executed within your pipeline, make sure you connect the lines between the actions. This ensures a functional flow and allows you to pass or transform data between actions.

Each plugin comes with a set of Methods which are the actual actions that the plugin will run. For example, the AWS EC2 plugin offers Methods to Create Instance, Reboot, Terminate instance, and many more.

To start the configuration process, select the first action from within your pipeline. In this example, the AmazonEC2 action allows you to configure the following fields as seen below.

Configure tab

The Configure tab displays different plugin parameters that are either mandatory or optional in order to run an action based on a chosen method.

EC2 Action Configuration:

Just as you would normally do when creating a new EC2 instance through AWS Management Console, you need to configure multiple instance details – such as methods, parameters, or functions. These fields can be manually filled in or dynamically generated at the time of the execution by using the Code fields.

In order to create basic EC2 machine, let’s fill up only most important fields:

  • ID: createec2
  • Display Name: Create EC2
  • Method: Create Instance
  • Access Key & Secret Key: Choose from Vaults your AWS Key and AWS Secret Key. Note that you should allow in IAM to do the operations with EC2 (link)
  • Region: Choose from list region (ex. eu-central-1) or click toggle and switch to code and type: ‘eu-central-1’
  • Image Id: To find proper AMI, use this site: https://cloud-images.ubuntu.com/locator/ec2/

Below example of search of AMI for Ubuntu 20.04 LTS and region eu-central-1. Copy-paste AMI-ID to the field Image ID

  • Instance type: lets use instance from AWS Free Tier, and fill the field: t2.micro

Slack Action Configuration:

In order to configure Slack action, fill up ID, Display name and choose method “Send Incoming Webhook“. Create Webhook from Slack application (APPS -> Incoming WebHooks -> Add) and copy it’s Value to the Vault section, and fill up field Webhook URL. 

Next fill up the Message with the information about “Sucess” (more advanced option is to pass instance id like describen below)

  1. Basic Version: Just fill up Field message with “EC2 Created”

2. Advanced Version: Add function to retrieve instance ID to the Code layer, and call this function from the Message field

function getSlackMessage(){ return `New Instance ID: ${actions.createec2.result.runInstances.Instances[0].InstanceId}`}

That configured two actions you can save, and execute.

 

 

Other possible configurations:

EC2 Plugin

  • Action ID : This field allows you to access the status, inputs and outputs of the action.
  • Display Name : Choose a name that will be displayed in the Design layer.
  • Description : Enter an optional description of the action.
  • Method : Choose the method that will be used when executing the action – in this case, select Create Instance.
  • Access Key & Secret Key : Enter the key IDs used to authenticate to AWS for this request. To securely pass it, use vault items to store your keys, tokens, passwords, or other secrets in the Kaholo Vault for ease of access. See Creating Vault Items for more details.
  • Region : Select the region you want the request to be executed in.
  • Image ID : Fill in the Amazon Machine Image (AMI) required to launch an instance.
  • Instance Type : Fill in the machine type you want to launch.
  • Key name : If specified, encrypt the volume created for this instance using the specified Key pair.
  • Security Groups IDs : This field allows you to connect this instance to a security group. You will have to use a code or configuration to transfer the array to the API.
  • User Data : This option allows you to pass user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts.
  • Minimum/Maximum Of Instances : The minimum/maximum number of instances to launch. By default, the value is set to 1 for both.
  • Subnet ID : You can specify a subnet ID to host the instance.
  • Tags Specification : Specify tags to apply to the resources during the launch.

 

Advanced tab

The Advanced tab allows you to add conditional statements when running a certain action.

  • Timeout : In this field, you may define the timeout period for the action runtime.
  • Retries : In this field, you may define the amount of retries of the action if it fails.
  • Conditions : In this field, you may determine if the action should execute. Returns a boolean value. You can reference code within the pipeline code layer.
  • Hooks : In this field, the function will run with an agent context before or after the action is executed. The result will be added to the context

For example, you may want to upload your repository on the EC2 server only when the instance has been created and made available. To do this, follow the steps below:

  1. Create separate action to do any action with the EC2 (ex. upload your code)
  2. In the Advanced tab under Conditions, enter the conditional code that will determine if the EC2 instance is available and if the action should be executed: isAvailable.

Code fields

An alternative to manually filling in plugin parameters is enabling the Code option by switching on the toggle above the parameter field. This way, parameter values can be dynamically generated at the time of execution.

For example, when configuring the new Amazon EC2 instance, you can dynamically get access to the auto-assigned IP address of the Host URL. To generate this value dynamically at the time of execution, you can use the following structure directly in a plugin parameter field that has the code option turned on:

actions.ec2NewInstance.result.PublicIpAddress

The ec2NewInstance serves as the Action ID, which is used to access the status, inputs and outputs of this action from any code field or from the Code layer.