Configuration & Usage
Detailed configuration, credential resolution order, caching, and runtime behavior for the bx-google-secrets module.
This guide covers effective settings, credential source precedence, local development, and operational behavior for bx-google-secrets.
๐ง Configuration Sources
Each setting is resolved independently in this order:
this.googleinApplication.bx(per-application)Module settings in
boxlang.json(global)Google environment variables / Application Default Credentials
๐งฉ Application.bx (Per-App)
Use this.google when each app needs isolated project or credential behavior.
class {
this.name = "myApp"
this.google = {
projectId : "my-gcp-project",
credentialsPath : "${GOOGLE_APPLICATION_CREDENTIALS}",
credentialsJson : "",
cacheTTL : 300
}
}When this.google is present, the module creates and reuses a dedicated SecretManagerServiceClient for that application.
๐ Global boxlang.json Settings
๐ฑ Environment Variable Fallback
Supported environment mappings:
projectId
GOOGLE_CLOUD_PROJECT, fallback GCLOUD_PROJECT
credentialsPath
GOOGLE_APPLICATION_CREDENTIALS
credentialsJson
GOOGLE_CREDENTIALS_JSON
If explicit credentials are not configured, the module can also rely on Google Application Default Credentials from environments such as Cloud Run, GKE, Compute Engine, App Engine, or a locally authenticated gcloud session.
๐ Settings Reference
projectId
string
""
Google Cloud project ID required for secret resolution
credentialsPath
string
""
Optional service account JSON file path
credentialsJson
string
""
Optional raw service account JSON content
cacheTTL
numeric
300
Cache time-to-live in seconds
๐ Usage Examples
Resolve a secret directly:
Resolve with a fallback value:
Use in datasource config:
๐ง Caching Behavior
Cache key format is
projectId:secretNameSuccessful secret fetches are cached in-memory
Expired entries are refreshed on next access
Set
cacheTTLto0for effectively no cache reuse
๐ Client Lifecycle
Per-app client: Used when
this.googleexistsGlobal client: Used when module settings provide project-based config
ADC/env client: Used when relying only on environment credentials or Google Application Default Credentials
Per-app clients are closed on application shutdown, and all clients are closed on module/runtime shutdown.
๐งช Local Development with gcloud
Authenticate with Google Cloud CLI and set a project:
Minimal module settings:
๐จ Troubleshooting
Secret returns
null: verifyprojectIdis resolved and the secret exists in Google Secret ManagerLicense errors: confirm
bx-plusis installed and licensed; for local testing, setBX_GOOGLE_DEV=truePermission errors: ensure the runtime identity can access secret versions
Wrong module settings key: use
bxgoogle-secretsundermodulesinboxlang.json
Last updated
Was this helpful?
