Quickstart: Deploying a Cloud Run service with Cloud Code

This page shows you how to get started with Cloud Code.

You'll set up a Hello World service that runs on Cloud Run using a starter template, deploy your service to Cloud Run, and view the status of your live service's resources.

Creating a new Cloud Run service with Cloud Code

Before you begin

To use Cloud Run, you'll create a GCP project and enable billing.

Additionally, you'll need to enable Cloud Run support on your project. In the Console, use the navigation menu to access APIs and Services > Dashboard. Click on Cloud Run API within the list of available APIs and click Enable API.

Installing Cloud Code

To install the Cloud Code plugin:

  1. Install JetBrains IDE version 2020.1+ (such as IntelliJ Ultimate/Community, PyCharm Professional/Community, WebStorm, GoLand), if you haven't already.
  2. Install dependencies:
    • For all Cloud platforms, ensure the Docker client (authenticated with your Docker registry) is installed on the PATH of your machine. (Its respective folder should be visible under a directory within your PATH.) To check if you already have Docker installed, run docker -v.
    • Cloud Code automatically installs other necessary dependencies.
  3. Open IntelliJ IDEA (or any supported JetBrains IDE).
  4. From your plugins marketplace (File > Settings > Plugins or for Mac OS X, IntelliJ IDEA > Preferences > Plugins), search for the 'Cloud Code' plugin and install it. You may be prompted to restart your IDE to activate the plugin.

Creating a service

To create a new service using an existing sample:

  1. In your IDE, open File > New Project and select Cloud Code: Cloud Run.
  2. Select a 'Hello World' template from the list of starter applications. Creating a service from a list of existing sample apps
  3. Pick a name for your project.

    Once you click Finish, Cloud Code will clone your chosen template, open your newly created project for use, and create necessary Cloud Run run configurations.

    • For Java templates, you'll be prompted to import Maven projects to sync your pom.xml. Click 'Add as Maven project'.

      Non-managed pom.xml notification

      Additionally, import necessary Maven projects by clicking 'Import Changes'.

      Import Maven changes notification

Deploying your service to Cloud Run

To deploy your service, follow these steps:

  1. Choose the automatically created run configuration, Cloud Run: Deploy, from the Run/Debug configurations selector in the Navigation bar.
  2. Click Run run action icon. This brings up the Edit configuration window.
  3. Set your Google Cloud project ID.
  4. Choose a region for your deployment platform. This quickstart uses the default platform option, Cloud Run (fully managed), as the Deployment Platform.
  5. Click Run.
  6. View your running service by following the URL displayed in the output window.
  7. You can also view the status of your service (metrics, revision details, and more) by following the logs URL displayed in the output window.

    Viewing the status of your service in the Console

Viewing resource status

To view the status of your running service's resources, follow these steps:

  1. Navigate to the Cloud Run Explorer. It can be accessed from the sidebar panel on the right.

    Cloud Run explorer tab highlighted on the right hand-side panel

  2. Click on a service or a revision in the explorer to display its properties.

    Cloud Run explorer open with a service selected and its properties displayed below

  3. Right-click a revision to view its logs.

    Right-click on a revision to view its logs

Cleaning up

If you created a project for this quickstart, be sure to delete it to avoid unnecessary charges:

  • Go to the Projects page in the Cloud Console:

    Go to the Projects page

  • Select the project you created for this Quickstart and click on the trash can icon next to delete it.

    This shuts down the project and schedules it for deletion.

If you're using a pre-existing project and would like to delete resources you created for this quickstart:

  • Container image: While Cloud Run does not charge when the service is not in use, you might still be charged for storing the container image in Container Registry. To delete your image, follow this guide.
  • Cloud Run service: To delete a Cloud Run service, navigate to Cloud Run in the Console using the navigation menu. Select the service you'd like to delete and click on the 'Delete' trash can icon.

What's next

Getting support

To send feedback, report an issue on GitHub or ask a question on Stack Overflow.