How to create a virtual machine using an instance template in GCP

In the previous article we have learned how-to-create-a-virtual-machine-in-gcp in this article we will learn how to create an instance using an instance template in GCP.

First of all we will learn what is the instance template and why it is needed in GCP.

In Google Cloud Platform (GCP), an instance template is a configuration template that you can use to create virtual machine (VM) instances and managed instance groups (MIGs) with a consistent set of properties. It encapsulates the machine type, boot disk image or container image, labels, and other instance properties into a reusable format.


You must have GCP account access.

1) Log in to your GCP account and navigate into your project.
Under your project navigate to compute instance dashboard.

Once you are on the compute instance dashboard click on the instance template option as shown in the below screenshot.

2) Next, provide a name to your instance template and then select the Machine configuration as per your use case.
If you are unaware of the GCP machine types please visit the official documentation below

3) Then choose the machine type suitable for your workload and the boot type.
Here I am choosing a Debian image and storage of 10GB.

A default service account will be created after the creation of the compute engine.
Also if you want to add a modified firewall setting check the boxes.
If you need to add ssh-keygen and configure networking and VCP you need to check the additional settings option.

After checking the necessary options click on Create.

Your new instance template will be displayed in the dashboard as shown below.

Creating a virtual machine using the template created.

From the 3 dots click on Create VM option as shown below.

Next, you will be forwarded to a virtual machine creation page as shown below

As shown in the below image your instance template is already selected and all the configurations in the template will be automatically added here also all we need is to click on create an instance and thus a new instance will spin up.

You might be wondering what is the purpose of doing this but the exact use case of the instance template is when we configure autoscaling for our instance.
During autoscaling, it launches a new instance using these templates provided.
This is similar to aws launch template.

In this small article, we have learned how to create a virtual machine using an instance template in GCP.

Leave a Reply

Your email address will not be published. Required fields are marked *