Jump to Content
Developers & Practitioners

Run code samples directly in the Google Cloud documentation

September 14, 2021
https://storage.googleapis.com/gweb-cloudblog-publish/images/Option_32x.max-2600x2600.jpg
Cyrus Maden

Technical Writer

We’re excited to announce a new documentation feature that lets you run code samples in Cloud Shell, without leaving the page. Sign in to your Google account, open Cloud Shell’s online terminal in the documentation, and run code as you’re reading about it:

https://storage.googleapis.com/gweb-cloudblog-publish/original_images/image8_2V7sevi.gif

This new feature makes it easier to explore Google Cloud by putting Cloud Shell at your fingertips. Now you don’t need to switch between the documentation and a terminal window to run the commands in a tutorial. The documentation has everything you need to try new products and services.

Cloud Shell even has common command-line tools and programming languages already installed, so you don’t need to track down libraries or deal with dependencies. Your development environment is always ready to use and up to date—just activate Cloud Shell and get started.

Activate Cloud Shell

Cloud Shell is available throughout our documentation set on Chrome desktop browsers (version 74 or higher). To use Cloud Shell in the documentation, sign in and click the Activate Cloud Shell button at the top of the page.

https://storage.googleapis.com/gweb-cloudblog-publish/images/image9_8zzFAgx.max-800x800.png

When Cloud Shell is activated, you see a terminal at the bottom of the page. Select a Google Cloud project to use Cloud APIs and access your resources:

https://storage.googleapis.com/gweb-cloudblog-publish/images/image6_IMxGEKp.max-1000x1000.png

Get started fast

Cloud Shell has the Cloud SDK already installed, so you can get started right away—no setup required. After you activate Cloud Shell and set a Cloud project, you can use tools like gcloud to try new services as you read about them.

For example, you can use the terminal in the documentation to complete a Pub/Sub quickstart in seconds:

https://storage.googleapis.com/gweb-cloudblog-publish/original_images/image10.gif

The terminal stays open when you go to a new page, so it’s easy to learn more and build solutions. When you’re done with the Pub/Sub quickstart, use your resources to create an app that authenticates mobile clients:

https://storage.googleapis.com/gweb-cloudblog-publish/original_images/image1_ny1LnAF.gif

Manage resources

Let’s say that you deployed a web app and now you’re onboarding a team member to manage it. You want to grant access to your resources, so you’re looking for commands that update the project’s permissions.

The terminal in the documentation makes this easy. List your Pub/Sub topics as you search for commands in the gcloud reference, and then set an IAM policy on a Pub/Sub topic as you read a guide about granting access to resources.

Keep developing

If you’re using Cloud Client Libraries, you can customize and run sample code in the Cloud Shell Editor. To use it, activate Cloud Shell and click Open Editor:

https://storage.googleapis.com/gweb-cloudblog-publish/images/image2_CBwd3Kz.max-1400x1400.png

The button opens the Cloud Shell Editor in a new tab. The online code editor has rich language support, local emulators, and more features that make it easy to build solutions with your favorite client library.

Try it out

We hope that the terminal in the documentation makes it easier to learn about Google Cloud and manage your resources. Not sure where to start? Activate Cloud Shell on these pages:

Posted in