Skip to content

Latest commit

 

History

History
62 lines (49 loc) · 2.88 KB

File metadata and controls

62 lines (49 loc) · 2.88 KB

Google Cloud Core Spring Boot Starter

Maven coordinates, using Spring Cloud GCP BOM:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-gcp-starter-core</artifactId>
</dependency>

Gradle coordinates:

dependencies {
    compile group: 'org.springframework.cloud', name: 'spring-cloud-gcp-starter-core', version: '1.0.0.M1'
}

This starter creates and configures two important configuration sources: CredentialsProvider and GcpProjectIdProvider.

It tries to read configuration from the application properties. For example, using a properties file:

spring.cloud.gcp.project-id=[YOUR_GCP_PROJECT_ID]
spring.cloud.gcp.credentials.location=file:[LOCAL_PRIVATE_KEY_FILE]
spring.cloud.gcp.credentials.scopes=[SCOPE_1],[SCOPE_2],[SCOPE_3]

If spring.cloud.gcp.project-id is populated, the provided GcpProjectIdProvider returns that project ID. Otherwise, it uses google-cloud-java’s rules to discover the project ID.

Similarly for spring.cloud.gcp.credentials.location, if a property is configured, the provided CredentialsProvider returns credentials for that private key. The value of spring.cloud.gcp.credentials.location is a Spring Resource, so you can specify file system paths, HTTP URLs, etc. If no property is configured, the provided CredentialsProvider returns the application default credentials.

If your app is running on Google App Engine or Google Compute Engine, in most cases, you should omit the spring.cloud.gcp.credentials.location property and, instead, let the Spring Cloud GCP Core Starter get the correct credentials for those environments. On App Engine Standard, the App Identity service account credentials are used, on App Engine Flexible, the Flexible service account credential are used and on Google Compute Engine, the Compute Engine Default Service Account is used.

spring.cloud.gcp.credentials.scopes is a comma-delimited list of Google OAuth2 scopes for Google Cloud Platform services that the credentials returned by the provided CredentialsProvider support. If unspecified, list of default scopes for every service supported by this project is used.