I'm using GoogleSecretManagerSettingsSource, and I would like to lazily load some secrets so they are only fetched when actually accessed. The current implementation fetches every single secret defined in the Settings class from Google Secret Manager during initialization, regardless of whether those secrets will actually be used.
This eager loading is the expected behavior, but it causes some isues:
- Performance penalty: Each secret fetch is a network call to GCP
- Unnecessary costs: GCP charges per secret access, so fetching unused secrets wastes money
- No conditional loading: Can't skip secrets based on environment (dev vs prod) or feature flags
Ideally, the solution would allow the following:
For example, in my application some modules use only a subset of settings. Currently, importing the settings class triggers GCP secret access even if the code path will not require those secrets.