Baby's First Google Compute Instance
Goal
By the end of this post, you will be able to create your own virtual machine using Google's Compute Engine.
A virtual machine is the server that can be used to run applications on the internet. Imagine you are building a house on a completely vacant tract of land. The virtual machine is like the foundation and basic structure of the house.
Just as a foundation provides the essential platform to build rooms, install utilities, and add furniture, a virtual machine provides the basic computing environment needed to run applications, manage resources, and host services. Without proper infrastructure in both cases, nothing built on top can function properly or reliably.
Steps
Visit console.cloud.google.com and create a new project. GCP requires you to setup a project in order to access cloud infrastructure products.
Click on the "Select a project" drop down and choose "NEW PROJECT".
Give the project a name. For example, project-1
. Click "CREATE."
If you are not automatically directed to your project, use the "Select a project" drop down, choose the new project. In this case project-1
.
Next we need to setup a virtual machine (VM). Use the search bar and type "Compute engine." Select "Compute Engine" from the results.
Click "ENABLE" to enable the Compute Engine API. All products in GCP are APIs. Billing must be enabled at this point, though enabling the Compute Engine API is free.
Click "CREATE INSTANCE." An instance is a VM that runs on Google's infrastructure.
Provide a name for the instance. The name must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen. For example, instance-1
.
For region, choose the region closest to your current location. For example, us-central1 (Iowa)
. For Zone, choose "Any."
For machine configuration, choose E2
which is Google's recommendation for "Low cost, day-to-day computing."
Choose e2-micro
for "Machine type," which is the least expensive option.
At this point we have an instance of GCP's Compute Engine ready to be created with an estimated cost of $7.11 per month. Unless you are getting traffic or running background processes, your bill will be much lower. You should expect to spend less than $1.00 on GCP by the completion of the Rails Deployments for Mere Mortals guide. If you shutdown your instance after that, your bill should not increase. A detailed discussion of GCP pricing is beyond the scope of this guide and I encourage you to investigate this topic to avoid unexpected charges.
Click "CREATE."
Voila! A shiny new VM on Google Cloud Platform.
Click "instance-1"
Click "EDIT"
Scroll down to "Firewalls" and check all three options.
Click "SAVE"
Now we've allowed three types of traffic to access our VM, HTTP
, HTTPS
, and Load Balancer Health checks. This is kind of like connecting our house's driveway to the nearby street.
Click the back arrow to return to the VM instances page in Google Cloud Console.
Conclusion
There is actually a little corner of a server in some immense Google data center that we just started to lease. We now have the foundation of our house.
In the next post, Secure Shell Key Generation, we will use the ssh keygen
command to generate a Secure shell key that we will use to authenticate with our new VM.
To extend the metaphor, we'll be picking out the lock for the front door of our house.
Member discussion