Micronaut GCP

Provides integration between Micronaut and Google Cloud Platform (GCP)

Version: 1.1.0

1 Introduction

This project provides various extensions to Micronaut to integrate Micronaut with Google Cloud Platform (GCP).

2 Setting up GCP Support

The micronaut-gcp-common module includes basic setup for running applications on Google Cloud.

compile 'io.micronaut.gcp:micronaut-gcp-common:1.1.0'


  1. You should have a Google Cloud Platform project created

  2. Install gcloud CLI

  3. Configure default project gcloud config set project YOUR_PROJECT_ID

  4. Authenticate with gcloud auth login

  5. Authenticate application default credential with gcloud auth application-default login

It’s strongly recommended that you use a Service Account for your application.

Google Project ID

The module features a base GoogleCloudConfiguration which you can use to configure or retrieve the GCP Project ID:

Table 1. Configuration Properties for GoogleCloudConfiguration
Property Type Description



Sets the project id to use.

You can inject this bean and use the getProjectId() method to retrieve the configured or detected project ID.

Google Credentials

The module will setup a bean of exposing the com.google.auth.oauth2.GoogleCredentials instance that are either detected from the local environment or configured by GoogleCredentialsConfiguration:

Table 2. Configuration Properties for GoogleCredentialsConfiguration
Property Type Description



The default scopes to associate with the application to access specific APIs. See <a href="https://developers.google.com/identity/protocols/googlescopes">Google Scopes</a> for a complete list. Leave this empty if you don’t need additional API access.



Sets the Base64 encoded service account key content..



Sets the location to the service account credential key file.

3 Stackdriver Trace

The micronaut-gcp-tracing integrates Micronaut with Stackdriver Trace.

To enable it add the following dependency:

compile 'io.micronaut.gcp:micronaut-gcp-tracing:1.1.0'

Then enabling Zipkin tracing in your configuration application.yml:

Enabling Stackdriver Trace
        enabled: true
        # [Optional] Set sampling probability to 100% for dev/testing purposes to observe traces.
        # sampler:
        #    probability=1.0

# [Optional] configuration to enable/disable Stackdriver Trace configuration.
# This is defaulted to true.
# gcp:
#    tracing:
#        enabled: true