Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
gcf-runtime-config
Advanced tools
Readme
gcf-runtime-config
helps you
get environment variables within Google Cloud Functions (GCF) through
Runtime Config
.
$ npm install --save gcf-runtime-config
$ gcloud services enable runtimeconfig.googleapis.com
Create a new config:
$ gcloud beta runtime-config configs create EXAMPLE_ENVIRONMENT
$ gcloud beta runtime-config configs variables \
set PAYPAL_SECRET_KEY "NOTREAL1234!@#$" \
--config-name EXAMPLE_ENVIRONMENT \
--is-text
$ gcloud beta runtime-config configs variables \
set STRIPE_SECRET_KEY "YESREAL1234!@#$" \
--config-name EXAMPLE_ENVIRONMENT \
--is-text
const gcfRuntimeConfig = require('gcf-runtime-config');
exports.testRuntimeConfig = (req, res) => {
gcfRuntimeConfig
.getVariables('EXAMPLE_ENVIRONMENT')
.then(variablesObj => res.send(variablesObj))
.catch(err => res.send(err));
};
The example
directory is a ready-to-deploy sample function that uses
gcf-runtime-config
and extracts a runtime config (environment).
$ gcloud beta functions deploy testExpressApp --trigger-http
$ curl https://<YOUR_PROJECT>.cloudfunctions.net/testRuntimeConfig
{"PAYPAL_SECRET_KEY":"NOTREAL1234!@#$","STRIPE_SECRET_KEY":"YESREAL1234!@#$"}
$ gcloud beta functions delete testExpressApp
Arguments:
EXAMPLE_ENVIRONMENT
.{"PAYPAL_SECRET_KEY":"NOTREAL1234!@#$","STRIPE_SECRET_KEY":"YESREAL1234!@#$"}
[{"name":"STRIPE_SECRET_KEY","updateTime":"2018-05-20T09:53:11.383980095Z","text":"YESREAL1234!@#$"},{"name":"PAYPAL_SECRET_KEY","updateTime":"2018-05-20T09:53:09.683262561Z","text":"NOTREAL1234!@#$"}]
Returns:
A Promise
that depending on objectify
resolves to either an object where its
keys and values are the config's parameters and values or to an array of parameter objects.
We needed a way to inject secret keys to a Google Cloud Function. Storing keys in code base is wrong.
MIT
FAQs
Environment Variables within Google Cloud Functions through Runtime Config
The npm package gcf-runtime-config receives a total of 2 weekly downloads. As such, gcf-runtime-config popularity was classified as not popular.
We found that gcf-runtime-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.