Deploy a Cloud Run service with Cloud Code for IntelliJ

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 sample application, deploy your service to Cloud Run, and view the status of your live service's resources.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Cloud Run API.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Enable the Cloud Run API.

    Enable the API

  8. Install Git so that Cloud Code can perform Git operations, like cloning a sample.
  9. Install the Cloud Code plugin if you haven't already.

Creating a service

To create a new service using an existing sample:

  1. In your IDE, open File > New Project and then select Cloud Code: Cloud Run.
  2. Select the programming language for your sample application and then click Next. Creating a service from a list of existing sample apps
  3. Name your project and then click Finish.

    Cloud Code clones the sample application, opens your newly created project for use, and creates the necessary Cloud Run run configurations.

  4. If you chose a Java sample application, when prompted, click Load Maven project.

    Maven build scripts found notification - choose Load Maven Project, Skip, or Help

You can now run your Hello World service. Cloud Code watches your filesystem for changes so that you can edit and rerun your service in near real time.

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 action icon Run. 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 Google Cloud 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. To display a service or revision's properties, click the service or revision in the explorer.

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

  3. To view a revision's logs, right-click the revision and then click View Cloud Logs.

    Right-click 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:

  1. Go to the Projects page in the Google Cloud console:

    Go to the Projects page

  2. Select the project you created for this quickstart and then click Delete.

    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 doesn't charge when the service isn't in use, you might still be charged for storing the container image in Container Registry. To delete your image, follow the steps in Deleting images.
  • Cloud Run service: To delete a Cloud Run service, navigate to Cloud Run in the Google Cloud console using the navigation menu. Select the service you'd like to delete and then click Delete.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.

What's next