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.
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:
- Install JetBrains IDE version 2020.1+ (such as IntelliJ Ultimate/Community, PyCharm Professional/Community, WebStorm, GoLand), if you haven't already.
- Install dependencies:
- For all Cloud platforms, ensure the
Docker client (authenticated with your
Docker registry) is installed on the
PATHof your machine. (Its respective folder should be visible under a directory within your
PATH.) To check if you already have Docker installed, run
- Cloud Code automatically installs other necessary dependencies.
- For all Cloud platforms, ensure the Docker client (authenticated with your Docker registry) is installed on the
- Open IntelliJ IDEA (or any supported JetBrains IDE).
- 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:
- In your IDE, open File > New Project and select Cloud Code: Cloud Run.
- Select a 'Hello World' template from the list of starter applications.
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'.
Additionally, import necessary Maven projects by clicking 'Import Changes'.
Deploying your service to Cloud Run
To deploy your service, follow these steps:
- Choose the automatically created run configuration, Cloud Run: Deploy, from the Run/Debug configurations selector in the Navigation bar.
- Click Run . This brings up the Edit configuration window.
- Set your Google Cloud project ID.
- Choose a region for your deployment platform. This quickstart uses the default platform option, Cloud Run (fully managed), as the Deployment Platform.
- Click Run.
- View your running service by following the URL displayed in the output window.
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 resource status
To view the status of your running service's resources, follow these steps:
Navigate to the Cloud Run Explorer. It can be accessed from the sidebar panel on the right.
Click on a service or a revision in the explorer to display its properties.
Right-click a revision to view its logs.
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:
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.
- Add Google Cloud APIs and client libraries to your project.
- Customize your run configurations with advanced settings.
- Try creating and running a Kubernetes application with Cloud Code.