I am using Google Cloud Secrets in a NodeJS Project. I am moving away from using preset environment variables and trying to find out the best practice to store and reuse secrets.
The 3 main routes I've found to use secrets are:
- Fetching all secrets on startup and set them as ENV variables for later use
- Fetching all secrets on startup and set as constant variables
- Each time a secret is required, fetch it from Cloud Secrets
Google's own best practice documentation mentions 2 conflicting things:
- Use ENV variables to set secrets at startup (source)
- Don't use ENV variables as they can be accessed in debug endpoints and traversal attacks among other things (source)
My questions are:
- Should I store secrets as variables to be re-used or should I fetch them each time?
- Does this have an impact on quotas?