Google Cloud Platform (GCP) Activities are available for Public Preview

Description

Update: :loudspeaker: :loudspeaker::loudspeaker: Google Cloud Platform activities are now available on the Official Stable Feed!

In addition to existing activities for managing virtual machine instances, it offers activities for automating operations with buckets and objects.

image

UiPath.GoogleCloud.Activities package offers activities for Google Cloud Platform (GCP).

This set of activities enables IT Departments to easily automate processes related to the provisioning, management, and maintenance of virtual machine instances hosted on Google Cloud Platform. Here are some of the automation that can be created using this package:

  • Provision new servers.
  • Reset, start, stop, and delete VM instances.
  • Run scripts inside the VMs (without remoting).
  • Green computing and cost control (e.g., stopping the instances that should not be running 24/7).

Activities List

Cloud > Google

Google Cloud Scope – Connects to Google Cloud and provides a scope for other Google Cloud activities.

Cloud > Google > Compute Engine > Instances

Create Instance Creates a new instance. An instance is a virtual machine that is hosted on Google Cloud Platform.
Create Instance from Template - Creates a new instance from an instance template.
Get Instance – Gets the details of the specified instance.
For Each Instance – Performs an activity or a series of activities on each instance matching the filter criteria.
Start Instance – Starts an instance.
Stop Instance – Stops a running instance.
Reset Instance – Resets an instance. This is a hard reset; it is not a graceful shutdown.
Delete Instance – Deletes an instance.
Configure Robot – Connects the Robot in a given instance to UiPath Orchestrator.
Run Script on Instance – Runs a script on an instance.

How to install

UiPath.GoogleCloud.Activities package is available in preview on the Official feed, as a prerelease. In the Official feed, check ‘Include Prerelease’, search for “UiPath.GoogleCloud.Activities” and install it.
** :exclamation:Important - We must reiterate, make sure you check the ‘Include Prerelease’ checkbox :blush:

Google Cloud Platform Activities should be visible now in UiPath Studio, as shown below:

How to use

The sample workflow below shows how to use Google Cloud Platform activities in practice.

Create new VM instances and stop those that should not be running 24/7

This UiPath process contains a workflow exemplifying how to create new instances from three different sources – image, snapshot, disk – and how to stop those instances which are not needed to be running 24/7 (to reduce costs). In this example, the instances that can be stopped are those containing a label with the key “alwayson” and value “false”.

GCP_Instances_Sample.zip (38.2 KB)

Let us go step by step through the process of creating the workflow:

  1. First, add a Google Cloud Scope activity to connect to GCP and to provide a scope for the other GCP activities. This activity has the following input parameters:

    • ServiceAccountKey (SecureString) - The service account key as a secure string.
    • ServiceAccountKeyFromFile (String) - The file path of the JSON file that contains your service account key.
    • ServiceAccountCredentialsMode (Enum) - Indicates how to pass the service account credentials. If your robot runs outside a Google Cloud environment, it is mandatory to select ‘ServiceAccountKey’ or ‘ServiceAccountKeyFromFile’. If your robot runs inside a Google Cloud environment, it is recommended to use ‘AutoDetect’ so the service account credentials will be automatically obtained.

    You can learn more about authentication in Google Cloud Platform by visiting Authentication at Google  |  Google Cloud and Understanding service accounts  |  IAM Documentation  |  Google Cloud

  2. Then, let us create three instances using Create Instance activity. Before creating an instance, the first step is to prepare the labels for the instance, as a DataTable object. For this, use a Build Data Table activity. Two of the instances will have value “false” for the label with key “alwayson” and one instance will have value “true” for the same label. The first instance uses an Image as source for the Boot Disk, the second uses a Snapshot, and the last one a Disk. Specify these sources by providing their selfLink value (an example is shown in the image below, a screenshot taken from Google Cloud Console).

    A short description of some of the activity’s parameters.

    • Name - The name of the instance.

    • Description (String) - The description of the instance.

    • Labels (DataTable) - The labels to associate with the instance. It shall contain two columns of type String, the first one representing the key and the second its value.

    • ProjectId (String) - The ID of the project to which the instance belongs.

    • Zone (String) - The name of the zone where the instance resides.

    • MachineType (String) - The predefined machine type. For example, “e2-medium”. See available values for MachineType here About machine families  |  Compute Engine Documentation  |  Google Cloud

    • WaitForCompletion (Boolean) - If set to ‘true’, the activity waits to complete before moving to the next activity.

    • Timeout (Numeric) - Specifies the amount of time (in seconds) to wait for the activity to run before an error is thrown. If not set, the activity runs until completion.

    • SourceType (Enum) - Specifies the source type. Possible values: {Image, Snapshot, Disk}.

    • Source (String) - The image or snapshot used to create a boot disk, or an existing disk to attach to.

    • DiskType (Enum) - The type of the boot disk to use. This parameter is ignored when SourceType is ‘Disk’. Possible values are {PersistentDiskStandard, PersistentDiskSSD, PersistentDiskBalanced}

    • SizeGb (Numeric) - The size of the boot disk. This parameter is ignored when SourceType is ‘Disk’.

  3. Now, let us retrieve all instances that can be stopped. In order to do this, use a For Each Instance activity with a simple Filter like "labels.alwayson = false”, or a more complex one “(labels.alwayson = false) AND (labels.creator = ovidiu-ponoran) AND (status = RUNNING)”. This activity has the following input parameters:

    • ProjectId (String) - The ID of the project to which the instances belong.

    • Zone (String) - Searches only for those instances in the specified zone.

    • LimitToFirst (Numeric) - The maximum number of instances to be returned by the activity. If not set, all instances matching the filter criteria are retrieved.

    • Filter (String) - The filter expression. For more details about the filtering capabilities, please read the description of filter field here Method: instances.list  |  Compute Engine Documentation  |  Google Cloud

  4. Finally, use a Stop Instance activity within For Each Instance to stop the instances. Just set the value for Instance parameter to gcpInstance . You can uncheck the WaitForCompletion option if you don’t want to wait for the activity to complete before moving to the next activity.

    You can see the result of running the workflow in Google Cloud Console:

That’s all folks :blush:!
I invite you to use these activities in your automation and let us know :writing_hand: what you think :thinking:.

9 Likes