An OpenFeature provider that reads feature flags from Google Cloud Parameter Manager, the GCP-native equivalent of AWS SSM Parameter Store.
<dependency>
<groupId>dev.openfeature.contrib.providers</groupId>
<artifactId>gcp-parameter-manager</artifactId>
<version>0.0.1</version>
</dependency>import dev.openfeature.contrib.providers.gcpparametermanager.GcpParameterManagerProvider;
import dev.openfeature.contrib.providers.gcpparametermanager.GcpParameterManagerProviderOptions;
import dev.openfeature.sdk.OpenFeatureAPI;
GcpParameterManagerProviderOptions options = GcpParameterManagerProviderOptions.builder()
.projectId("my-gcp-project")
.build();
OpenFeatureAPI.getInstance().setProvider(new GcpParameterManagerProvider(options));
// Evaluate a boolean flag stored in GCP as parameter "enable-dark-mode"
boolean darkMode = OpenFeatureAPI.getInstance().getClient()
.getBooleanValue("enable-dark-mode", false);Each feature flag is stored as an individual parameter in GCP Parameter Manager. The flag key maps directly to the parameter name (with an optional prefix).
Supported raw value formats:
| Flag type | Parameter value example |
|---|---|
| Boolean | true or false |
| Integer | 42 |
| Double | 3.14 |
| String | dark-mode |
| Object | {"color":"blue","level":3} |
The provider uses Application Default Credentials (ADC) by default. No explicit credentials are required when running on GCP infrastructure (Cloud Run, GKE, Compute Engine) or when gcloud auth application-default login has been run locally.
To use explicit credentials:
import com.google.auth.oauth2.ServiceAccountCredentials;
import java.io.FileInputStream;
GoogleCredentials credentials = ServiceAccountCredentials.fromStream(
new FileInputStream("/path/to/service-account-key.json"));
GcpParameterManagerProviderOptions options = GcpParameterManagerProviderOptions.builder()
.projectId("my-gcp-project")
.credentials(credentials)
.build();| Option | Type | Default | Description |
|---|---|---|---|
projectId |
String |
(required) | GCP project ID that owns the parameters |
locationId |
String |
"global" |
GCP location for the Parameter Manager endpoint ("global" or a region such as "us-central1") |
credentials |
GoogleCredentials |
null (ADC) |
Explicit credentials; falls back to Application Default Credentials when null |
cacheExpiry |
Duration |
5 minutes |
How long fetched values are cached before re-fetching from GCP |
cacheMaxSize |
int |
500 |
Maximum number of flag values held in the in-memory cache |
parameterNamePrefix |
String |
null |
Optional prefix prepended to every flag key. E.g. prefix "ff-" maps flag "my-flag" to parameter "ff-my-flag" |
GcpParameterManagerProviderOptions options = GcpParameterManagerProviderOptions.builder()
.projectId("my-gcp-project")
.locationId("us-central1")
.build();GcpParameterManagerProviderOptions options = GcpParameterManagerProviderOptions.builder()
.projectId("my-gcp-project")
.parameterNamePrefix("feature-flags/")
.build();GCP Parameter Manager has API quotas. Use a longer cacheExpiry to reduce quota consumption.
GcpParameterManagerProviderOptions options = GcpParameterManagerProviderOptions.builder()
.projectId("my-gcp-project")
.cacheExpiry(Duration.ofMinutes(10))
.cacheMaxSize(1000)
.build();Integration tests require real GCP credentials and pre-created test parameters.
- Configure ADC:
gcloud auth application-default login - Create test parameters in your project (see
GcpParameterManagerProviderIntegrationTestfor the required parameter names) - Run:
GCP_PROJECT_ID=my-project mvn verify -pl providers/gcp-parameter-manager -Dgroups=integration