Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing sensitive information to cloud functions

Is there an "official" solution for passing sensitive information, such as API keys, to Google Cloud Functions? In particular it would be nice to avoid passing this information as arguments to the function since it will be the same for every invocation. AWS Lambda has a built-in solution using encrypted environment variables for this. Is there some similar approach for Google Cloud Functions?

I could imagine using a cloud storage bucket or cloud datastore for this, but that feels very manual.

like image 204
dylan.scott Avatar asked Mar 22 '17 17:03

dylan.scott


People also ask

What can trigger cloud functions?

Because Cloud Functions can be triggered by messages on a Pub/Sub topic, you can integrate Cloud Functions with any other Google service that supports Pub/Sub as an event bus. In addition, by using HTTP triggers you can also integrate with any service that provides HTTP callbacks (webhooks).

Is cloud function stateless?

Google Cloud Functions is a stateless execution environment, which means that the functions follow a shared-nothing architecture. Each running function is responsible for one and only one request at a time.


2 Answers

If you're using Cloud Functions with Firebase, you're looking for environment configuration.

With that, you deploy configuration data from the Firebase CLI:

firebase functions:config:set someservice.key="THE API KEY" someservice.id="THE CLIENT ID"

And then read it in your functions with:

functions.config().someservice.id
like image 136
Frank van Puffelen Avatar answered Oct 01 '22 12:10

Frank van Puffelen


You can use Google Secret Manager. https://cloud.google.com/secret-manager/docs

See this article for an example: https://dev.to/googlecloud/using-secrets-in-google-cloud-functions-5aem

like image 40
Cristiana SP Avatar answered Oct 01 '22 12:10

Cristiana SP