This page shows you how to get started with Cloud Code.
You'll set up a Hello World application that runs on Cloud Run using a starter template, deploy your app to Cloud Run, and view the status of your live application'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 2019.2+ (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
- Cloud Code will automatically install install 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 an application
To create a new application 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 app to Cloud Run
To deploy your application, follow these steps:
- Choose the automatically created run configuration, Cloud Run: Deploy, from the Run/Debug configurations dialog on the top taskbar.
- 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 app by following the URL displayed in the output window.
You can also view the status of your application (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 application's resources, follow these steps:
Navigate to the Cloud Run Explorer. It can be accessed from the side 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.