Create a VM Instance in GCP Using Cloud SDK and gcloud

In this blog post, I will show you how to use Cloud SDK and gcloud to create a Virtual machine instance in Google Cloud Platform (GCP).

Following the previous blog post, where I showed how to manage resources using Cloud SDK, today, we will use to create a VM.

Instances

In Google Cloud Platform, virtual machines are called instances, or VM instances.

Get Code

For our convenience, when we create a VM instance using the console, GCP shows us the code to create it using Cloud SDK.

So let’s go ahead and create a VM using the console and scroll to the bottom of the page.

At the bottom of the page, we can see the equivalent command-line details of the create VM instance, go ahead and click on the command line link.

The command-line screen will show you the command to create the VM using gcloud; you can copy it and run it from Cloud SDK.

You can also use it as a baseline and add or remove feature change project and more.

The idea here is to save you time and effort but at the same time, teach you how to use gcloud.

Run command

I like to copy the code to a PowerShell script or Bash Shell script and run it.

View VM instances

After creating the VM, I can run the following commands to view all the instances in my project.

gcloud config set project ntweekly
gcloud compute instances list

Below, you can also see the VM in the console.

Processing…
Success! You're on the list.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.