Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Functions Environment Variables

Is it possible to set environment variables for GCF so that all that settings would be visible to all functions? Or maybe there are some options to configure it in project's scope?

I'm just need a mechanism to parametrize all environments, like local-dev, dev, stage, prod for functions. For now I'm trying setup local datastore emulator and setup local development/debugging/testing workflow without writing if statements inside code. As I found such things can be configured through env. veriables, but I'm don't know how it would work on target platform in cloud.

In future staging will be made by division environments onto separate cloud projects with their's own databases and storages as well as env. variables.

Is it possible or is there any solution for something like that?

like image 532
QuestionAndAnswer Avatar asked Apr 05 '17 09:04

QuestionAndAnswer


People also ask

How do I set environment variables in cloud run?

To set, update, or remove environment variables of an existing service, use the gcloud run services update command. You can use any of the following flags, as needed: --set-env-vars. --update-env-vars.

Are Google cloud functions serverless?

Google Cloud Functions is a serverless execution environment for building and connecting cloud services. With Cloud Functions you write simple, single-purpose functions that are attached to events emitted from your cloud infrastructure and services.


1 Answers

Not saying that Deployment Manager would not handle those the same way (although I could not spot it accurately), this below sounds like the closest answer to what you're talking about :

https://github.com/fredriks/cloud-functions-runtime-config/blob/master/README.md

Besides this example being an npm package, it shows clearly the gcloud commands to run.

It is important to activate the concerned api, as explained here (see 'before you begin')

like image 65
Ben Avatar answered Oct 13 '22 22:10

Ben