Doing a Google Cloud codelab? Start here!

1. Create a Google Cloud project and apply credits

While many Google Cloud products have a free tier, they still often require a credit card or other billing method on file. This codelab will walk you through setting up a $10 credit as your billing account so you don't have to input your billing information, and to give you some extra money to try out Google Cloud.

Prerequisites:

  • A Google account (preferably @gmail.com, not a G Suite account)

You can either create a new Google Cloud project (recommended), or apply this credit to an existing GCP project.

2. Get started with Cloud Shell

Google Cloud Shell is your Linux shell in the cloud: with just a browser you get command-line access to your cloud resources and optionally a text editor with syntax highlighting.

An example of Cloud Shell with terminal and text editor shown:

c63be5210e69eb64.png

Fully loaded, batteries included

Cloud Shell already has common developer tools installed like Node.js, Java, Go, Python, PHP, and Ruby. More of a sysadmin? Cloud Shell comes installed with a MySql client, PostgreSQL client, Kubernetes, Docker and more.

c5b8ba52a4e6b2fb.png

Begin the codelab

This Debian-based virtual machine is loaded with all the development tools you'll need. It offers a persistent 5GB home directory and runs in Google Cloud, greatly enhancing network performance and authentication. This means that all you will need for this codelab is a browser (yes, it works on a Chromebook).

  1. To activate Cloud Shell from the Cloud Console, simply click Activate Cloud Shell fEbHefbRynwXpq1vj2wJw6Dr17O0np8l-WOekxAZYlZQIORsWQE_xJl-cNhogjATLn-YxLVz8CgLvIW1Ncc0yXKJsfzJGMYgUeLsVB7zSwz7p6ItNgx4tXqQjag7BfWPcZN5kP-X3Q (it should only take a few moments to provision and connect to the environment).

I5aEsuNurCxHoDFjZRZrKBdarPPKPoKuExYpdagmdaOLKe7eig3DAKJitIKyuOpuwmrMAyZhp5AXpmD_k66cBuc1aUnWlJeSfo_aTKPY9aNMurhfegg1CYaE11jdpSTYNNIYARe01A

Screen Shot 2017-06-14 at 10.13.43 PM.png

Once connected to Cloud Shell, you should see that you are already authenticated and that the project is already set to your PROJECT_ID.

gcloud auth list

Command output

Credentialed accounts:
 - <myaccount>@<mydomain>.com (active)
gcloud config list project

Command output

[core]
project = <PROJECT_ID>

If, for some reason, the project is not set, simply issue the following command:

gcloud config set project <PROJECT_ID>

Looking for your PROJECT_ID? Check out what ID you used in the setup steps or look it up in the Cloud Console dashboard:

R7chO4PKQfLC3bvFBNZJALLTUiCgyLEq_67ECX7ohs_0ZnSjC7GxDNxWrJJUaoM53LnqABYamrBJhCuXF-J9XBzuUgaz7VvaxNrkP2TAn93Drxccyj2-5zz4AxL-G3hzxZ4PsM5HHQ

Cloud Shell also sets some environment variables by default, which may be useful as you run future commands.

echo $GOOGLE_CLOUD_PROJECT

Command output

<PROJECT_ID>
  1. Finally, set the default zone and project configuration.
gcloud config set compute/zone us-central1-f

You can choose a variety of different zones. For more information, see Regions & Zones.

In this codelab, you will learn how to connect to computing resources hosted on Google Cloud Platform via the web. You will learn how to use Cloud Shell and the Cloud SDK gcloud command.

Summary

In this step, you launched Cloud Shell and called some simple gcloud commands.

What you'll learn next

  • How to deploy a simple Node.js app to Google Cloud Platform
  • How to use gcloud commands

3. Try the Cloud Shell editor

Cloud Shell comes with a text editor you can use in your browser. To get started, first create a new directory for this codelab.

In the Cloud Shell command line, run the following commands:

touch hello-google-cloud.js
edit hello-google-cloud.js

This should automatically load the Cloud Shell editor. To open the editor without running the edit command, you can click the Open Editor button from the Cloud Shell command line.

Maximize the editor and terminal by clicking the "Open in new window" button.

63ec88931c39bf64.png

Your browser window with the Cloud Shell text editor and command line terminal should now look like this:

93363bc7bee5a90f.png

Write some code

Paste the following code snippet into the editor:

hello-google-cloud.js

function hello() {
  console.log('Hello, Google Cloud!');
}

hello();

Run your app

In the Cloud Shell command line terminal, run:

node hello-google-cloud.js

Success!

You should see the following output: Hello, Google Cloud!

Summary

You successfully opened the Cloud Shell Editor, which lets you visually edit files. You then ran your code using the Cloud Shell command-prompt.

4. Congratulations!

You got started with Google Cloud Platform and learned how to launch Cloud Shell and use the integrated editor.

Learn More

License

This work is licensed under a Creative Commons Attribution 2.0 Generic License.