[MUSIC PLAYING]
ANUBHAV SHANKAR: Hi, in this video,
we are going to learn about the new activity package that
has been released under IT Automation, which
is the Google Cloud Activities.
So to begin with, we will first see
how you can get the Google Cloud Activities
and for that, you have to go to the Manage Packages,
go to the Official feed, and in here you
can search for Google Cloud.
And you will get this package right at the Official feed
itself.
Click Install and click on Save, and your activities set
will be installed and will be available for you to use.
So now that the installation has completed,
you will see the activity set under Cloud.
And under Cloud, you will have this Google Activity package.
Under this name space, you have two kind of activities.
One is around the Compute Engine,
wherein we have the activities to take action on the instances
like creating the instance, deleting the instance,
creating instance from a template,
or running some kind of script on the instance.
We can have all those things done by simply dragging
and dropping these activities.
The second set of activities is around the storage.
And within Storage, you can look at both the Buckets
and the Objects.
Buckets are like containers within the Google Cloud
and you can use these activities to create, delete,
and basically play around with the buckets.
And similarly we have objects.
Objects are the files in the folders that are
contained within the buckets.
And if you want to do some activities around that,
you can use these activities to achieve the functionality.
We are going to look at both of these set of activities
by following some use cases in a bit.
But there is another activity, one of the important ones,
that I wanted to bring your attention to.
That is Google Cloud Scope.
And Google Cloud Scope is the activity set
that will help you in connecting to your Google Cloud instance.
So now let's begin by exploring the Instances
set of activities of which we have under Google Cloud.
And to explore this, we are going
to build a use case that will help
in performing some kind of virtual machine management.
So we are going to begin by creating the instances,
and for creating the instances, I
have this workflow file that is there for me.
And we are going to start by connecting it to the Google
Cloud instance that we have.
And for that, I'll just simply drag and drop
Google Cloud Scope activity within my work profile.
Now, the Google Cloud scope activity,
connects to your Google Cloud instance
by using service account keys.
And these can be provided in two forms,
either the service account key directly,
or you can simply point out to the file, the service account
key file that gets rated once you actually go ahead
and create a service account key file.
So how do you get this particular account file?
You can simply go to your Google Cloud instance,
in the IAM management.
Within that, you will get an option of Service Accounts.
Once you click on it, you can have the service account open.
Within that, you can go to the tabs called Keys,
wherein you can add new key.
And once you create a new key, you will get the file created.
So that's how you will get the JSON file created,
which I already have created for myself.
And it is stored within this particular project itself,
this is the JSON file.
And this is what I'm pointing out to this particular argument
that I have a service account key file.
So to start with, I'll say that I'm
going to use a service account key that
is available in my file, the one that was downloaded
from my Google Cloud instance.
And I will point out to the exact location
by attaching it to the correct variable.
Now that the Google Cloud Scope is ready
and it can talk to our instance, let's go ahead
and start creating the instance themselves.
For that, first of all, we are going
to create a data table which is basically
going to help us in recognizing the resources that I have.
So it is going to have a couple of things.
First of all the creator, which is going to be your name.
The second level is going to be always on label, which
when is set to true means that the robots will not
be able to search out these machines
when alwayson is set to false.
Will mean that the robots, whenever they run,
they can look for these kind of VMs
and those VMs can be stopped.
Basically, these VMs will be temporary VMs
that have been spawned by the robots.
And I'm going to actually associate it
to a variable called dtLabels that I have created right now.
And after this, I'm going to use a create instance
to actually go ahead and create the instance.
And in here, there are some interesting properties
that we are going to work through.
First of all, there are StartupScriptKey
and StartupScript parameters, wherein
you can mention the script that you want
to run when the system spawns.
And you can also mention what is that kind of system that
is there.
What is the kind of script that is there that you want to run?
Then you have the option of auto deleting the disk.
If you check this mark, which means that whenever
the instance that you have created, like in here,
is deleted, the associated disk will also be deleted.
And the next thing that you see in here
is the size in GB, which you can mention here as 20GB.
You have the option of choosing the disk
type, whether standard, balanced, or SSD.
And then you have the option of using the source image as well,
which I've already kept saved in one of my variables.
And you can see that in here this is the source image.
Then you have also other options of spawning these VMs.
And doing it from image, you can restore from a snapshot
or load it from a disk.
The next thing that is of interest to us
is obviously the labels that we have created.
We are going to associate the labels in here.
We are going to choose the machine
type that is preferred to us.
We will keep it really small, so we are good with micro.
We
Have to give the name of the system that is getting created.
For that, we have this.
So I'm using an instance name prefix
to recognize whatever resources are there for me just
by looking at the name, and then providing a unique ID.
Next is the ProjectId.
ProjectId is basically the project
wherein you want this resource to be created.
I have the ProjectId saved in my arguments.
I can mention it here directly.
And you can specify the timeout for this activity to run.
If not, it will wait until the completion.
And then there is this interesting parameter
called WaitForCompletion.
If this particular parameter is check
marked, where this is set to true,
will mean that until the instance is created,
the activity will wait for it.
If not, it will simply mean that the creation of the instance,
the command for creating the instance has already gone,
and the robot can move ahead.
So for now I'll keep it in unchecked.
I don't want to wait till the end of it.
Next is specifying the zone.
I have the zone saved as well.
And one of the variables in here,
it is going to be US Central.
And then, that's pretty much it.
This should be able to create my instance.
And the next thing that I want to do
is I will create the copy of this,
and I'll simply change the alwayson value to true
so that I have one temporary VM spawned up
and one dominant VM that is getting spawned.
Right?
Rest of the things is going to be the same, just
the label changes in here.
So let's see if we are able to spawn the VMs now.
I'll run this.
Permission for the first VM went off
and permission for the second VM went off.
So if I go to my engines and go back to VMs,
I should be able to see the two VMs that
has been spawned with the kind of naming convention
that I provided.
It is on the same zone, right.
So these two VMs are running.
If I go inside the detail of these VMs
and if I see the labels, I have the always false
for one of the VMs and for the second one,
the label is alwayson set to true.
Now let's go ahead and create another workflow which will
help us in managing these VMs.
Which means whenever these workflows will run,
it will basically help us in identifying the right kind
of VM and stopping it.
So we will start by doing the same process.
First of all, I'm going to use Google Cloud Scope to actually
get attached to the right instance.
I'll use Service Key Account from file.
I have it in my arguments, so I'll connect to it.
Now it'll be able to establish the connections.
The second thing that I would like to do
is I'm going to use an activity called For Each Instance.
What it does is it basically helps you
in filtering out the instance when you provide
the right kind of filters.
For me I'm going to show you what kind of filter
is going to be there for me.
So in here, if I go to the filters,
this is the filter that I'm going to use.
There is a label for alwayson.
That should be false.
And within the label of the creator is Anubhav Shankar--
that is me--
and the status is running.
If all these three conditions meets,
only then the instances will be selected
and the action is going to be taken on them.
So I'm going to set this.
I have to provide the ProjectId and the zone,
so I'll provide that as well.
It's going to be the same as before, these values.
And once I set this, I can actually
play around with this instance.
The first thing that I'm going to do
is let me log the information which instance
is going to be stopped.
So I will log this as an instance.
Then I'll give you instance.name is going to be stopped.
And then I'm going to actually stop the instance.
And for that, I'm going to refer to another activity
within the instances called Stop Instances.
I'll just simply drag and drop it in here.
And I have to provide the instance that
is going to be stopped, which is pretty easy.
And then I have the option of waiting for the instance
to be stopped and then proceed with the next one,
but right now, I'll keep it unchecked so
that we can see the result a lot quicker.
So let's see if this runs.
And it's done.
So if I go back to my instances, I
should see one of the instances stopped.
This is the instance that is being stopped at the moment.
You can see it here.
This is still being processed because I did not
wait for the completion.
The inspection went off, and the robot ended its job.
And the alwayson instance are still on,
even though those were also being filtered out
within the robot.
So that's how you do VM management using Google Cloud
Activities that has been released by IT Automation.
Thank you for watching
[MUSIC PLAYING]