Skip to content

Environment variables are not supported #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
blackxored opened this issue Dec 13, 2017 · 16 comments
Closed

Environment variables are not supported #92

blackxored opened this issue Dec 13, 2017 · 16 comments

Comments

@blackxored
Copy link

Environment vars (through environment under both provider and in the actual function declaration in serverless.yml doesn't seem to be supported. Furthermore, there isn't even a warning about it. As someone pretty much forced to deploy something on GCF as opposed to AWS Lamda this is rather confusing and an obvious feature to have. Is there somewhere I can find documentation about this?

@jbutz
Copy link
Contributor

jbutz commented Jan 24, 2018

As far as I can tell Google's Cloud Functions don't support environment variables. Google's API documentation for Functions doesn't seem to make any reference to them.

I haven't tried it, but you may be able to use the dotenv npm package along with including a .env file in the upload to Google to get environment variables loaded in.

I've also seen where people added build steps to create files to include instead of using environment variables. This is an article that I have seen written on the subject.

@aaronkchsu
Copy link

aaronkchsu commented Apr 25, 2018

I mean how far away is this feature?? :(

@adimoraret
Copy link

I was not able to make it work with dotenv npm package. I've installed serverless-dotenv-plugin which from the documentation looks more optimized for AWS rather than for Google Cloud.
I've got it working by putting environment variables in a separate js file, referencing it in index.js and make sure it's not included as part of commits :)

Totally a workaround which shouldn't be use in any production code. Too bad this feature is not yet available...

@hamikm
Copy link

hamikm commented Aug 13, 2018

+1 would love to see this feature

@jbutz
Copy link
Contributor

jbutz commented Aug 16, 2018

It looks like environment variables are a beta feature in Google's API now, so adding this feature shouldn't be too hard. It would be very similar to how I added labels (#95)

@nethunter
Copy link

I created a pull request that adds environment variables 2 weeks ago: #117

@mrdulin
Copy link

mrdulin commented Sep 21, 2018

Need this feature

@nethunter
Copy link

Need this feature

You can use my pull request (#117) for now, I've been using it for 2 months with no problems.

@mrdulin
Copy link

mrdulin commented Sep 21, 2018

@nethunter How can I use it?

@nethunter
Copy link

@mrdulin replace your serverless-cloud-functions line in package.json with this:

"serverless-google-cloudfunctions": "https://github.com/nethunter/serverless-google-cloudfunctions/tarball/master

and then in serverless.yml, under your provider add "environment" and add all the environment variables you want

@mrdulin
Copy link

mrdulin commented Sep 25, 2018

@nethunter thanks. It works. I made a sample for passing environment variables:

.env => serverless.yml => cloud functions

https://github.com/mrdulin/nodejs-serverless-framework/tree/master

@pickypg
Copy link
Contributor

pickypg commented Oct 23, 2018

Now that #117 is merged, this can be closed.

@pmuens
Copy link
Contributor

pmuens commented Nov 12, 2018

Thanks for opening @blackxored and thanks for updating @pickypg 👍

The latest version of this plugin supports env vars. Closing...

@pmuens pmuens closed this as completed Nov 12, 2018
@ncjones
Copy link

ncjones commented Mar 12, 2019

Where's the docs?

@pizzarob
Copy link

pizzarob commented Aug 2, 2019

@pmuens How can environment variables added via serverless.yml be used within cloud functions ?

@pizzarob
Copy link

pizzarob commented Aug 2, 2019

Nevermind it's the same as aws config. Can this be updated in the google cloud docs? Maybe a general section on general valid config options that works for every provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests