Environment variables with Google Cloud Functions



Hi guys,

Thanks for a great product!

Using the current master with GCF.

I was wondering if there was a way to specify environment variables to functions like in AWS.

Couldn’t find anything in the doc, and adding an “environment” section to the provider section doesn’t seem to work.

  name: google
  runtime: nodejs
  project: my-proj
  # the path to the credentials file needs to be absolute
  credentials: ~/.gcloud/keyfile.json
    STAGE: ${opt:stage}

When I try to read the environment variable STAGE in the functions, it is undefined
Works with AWS though.



Currently Google Cloud Functions does not support environment variables like AWS Lambda does. Its a feature they still need to add. Perhaps consider joining their Beta Google Cloud Functions mailing group to find out more.


I actually asked a similar question on SO a few days ago, since I wanted to handle the credentials through env variables (I wasn’t using Serverless at all then)

And no, no solution so far. Using Serverless is actually a solution for my use case since I can store the credential on the dev computer and run serverless which zip the credentials somehow, in a secure way I assume. But I don’t need to put the credential file in my git repository like I did before, which is much better anyway.