Skip to content

Environment variables are not supported #92

Closed

Description

@blackxored

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?

Activity

  1. jbutz commented on Jan 24, 2018

    @jbutz
    Contributor

    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.

  2. aaronkchsu commented on Apr 25, 2018

    @aaronkchsu

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

  3. adimoraret commented on Aug 10, 2018

    @adimoraret

    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...

  4. hamikm commented on Aug 13, 2018

    @hamikm

    +1 would love to see this feature

  5. jbutz commented on Aug 16, 2018

    @jbutz
    Contributor

    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)

  6. nethunter commented on Aug 31, 2018

    @nethunter

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

  7. mrdulin commented on Sep 21, 2018

    @mrdulin

    Need this feature

  8. nethunter commented on Sep 21, 2018

    @nethunter

    Need this feature

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

  9. mrdulin commented on Sep 21, 2018

    @mrdulin

    @nethunter How can I use it?

  10. nethunter commented on Sep 21, 2018

    @nethunter

    @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

  11. mrdulin commented on Sep 25, 2018

    @mrdulin

    @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

  12. pickypg commented on Oct 23, 2018

    @pickypg
    Contributor

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

  13. pmuens commented on Nov 12, 2018

    @pmuens
    Contributor

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

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

  14. ncjones commented on Mar 12, 2019

    @ncjones

    Where's the docs?

  15. pizzarob commented on Aug 2, 2019

    @pizzarob

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

  16. pizzarob commented on Aug 2, 2019

    @pizzarob

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions