GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — keyFilename makes 12-factor app style deployment difficult · Issue #136 · googleapis/google-cloud-node

keyFilename makes 12-factor app style deployment difficult #136

New issue
Copy link
New issue
Copy link
Closed
Closed
keyFilename makes 12-factor app style deployment difficult#136
Copy link
Assignees
stephenplusplus
Labels
🚨This issue needs some love.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Milestone
Core Stable

Description

@hulbert
hulbert
opened on Aug 26, 2014
Issue body actions

I'm trying to use cloud storage which the documentation says I should initialize as such:

var gcloud = require('gcloud'),
    bucket = new gcloud.storage.Bucket({
        bucketName: YOUR_BUCKET_NAME,
        keyFilename: '/path/to/the/key.json'
    });

I dug into the code and this keyFilename option seems to be the only way to specify this required info, and it expects a filepath string. This makes storing the key's JSON as an environmental variable pretty complicated since I'd have to write the env value to a file, then pass the path to gcloud.

This seems to be a similar issue someone faced with Google APIs, a key file, and Heroku: http://ar.zu.my/how-to-store-private-key-files-in-heroku/

As he outlines, it seems there are four options, none super simple:

  1. Include the private key in my git repository.
  2. Store it in S3, and pull it when needed.
  3. Use custom build-pack which will include the key.
  4. Store it as config vars.

Even just having the option to pass this information in as a Javascript object (which makes sense for a node library) would be nice.

Reacted by Michael Prentice

Activity

Next
  1. rakyll commented on Aug 26, 2014

    @rakyll
    rakyll
    on Aug 26, 2014
    Contributor
    More actions

    We should never assume that key file will be read from disk. We should require it to be passed as a plain object. Any other opinions?

  2. rakyll
    added this to the This milestone has been deleted milestone on Aug 26, 2014
  3. rakyll
    added
    bug
    on Aug 26, 2014
  4. silvolu commented on Aug 26, 2014

    @silvolu
    silvolu
    on Aug 26, 2014
    Contributor
    More actions

    I would add a key option to pass the object, but keep the keyFilename is as well.
    Some people like the 'download the key and pass the path to the constructor'™ approach, mostly in the getting started experience context.

  5. rakyll commented on Aug 26, 2014

    @rakyll
    rakyll
    on Aug 26, 2014
    Contributor
    More actions

    SGTM as we discussed offline.

  6. ryanseys commented on Aug 26, 2014

    @ryanseys
    ryanseys
    on Aug 26, 2014
    Contributor
    More actions

    Yes, both options is best. keyFilename: 'path/goes/here.json' should more or less just be an alias for key: require('path/goes/here.json') where key accepts a plain JavaScript object.

  7. rakyll commented on Aug 26, 2014

    @rakyll
    rakyll
    on Aug 26, 2014
    Contributor
    More actions

    keyFilename should work the way it works (without require), otherwise it becomes impossible to specify relative paths to keyFilename. See 7641028.

  8. ryanseys commented on Aug 26, 2014

    @ryanseys
    ryanseys
    on Aug 26, 2014
    Contributor
    More actions

    Interesting... I've never had issues with relative paths + require but I've never pushed it to its limits either. 😄

    fs.readFile is definitely better anyway because it's async and won't automagically cache. 👍

  9. hulbert commented on Aug 26, 2014

    @hulbert
    hulbert
    on Aug 26, 2014
    Author
    More actions

    Just an end-user perspective/question, is the entire JSON really needed or is it just using the private_key value? If you were to add a key option I would potentially be confused if this is to the whole object or just the value specified for the key private_key in the downloaded JSON file.

    This confusion might be worsened in my example of using environmental variables as I would likely break the JSON file into four ENV variables like so:

    declared environmental vars:

    GOOGLE_CLOUD_private_key_id=value
    GOOGLE_CLOUD_private_key=value
    GOOGLE_CLOUD_client_email=value
    GOOGLE_CLOUD_client_id=value
    GOOGLE_CLOUD_type=value
    

    Initializing gcloud-node:

    var gcloud = require('gcloud'),
        bucket = new gcloud.storage.Bucket({
            bucketName: YOUR_BUCKET_NAME,
            key: {
                "private_key_id": process.env.GOOGLE_CLOUD_private_key_id,
                "private_key": process.env.GOOGLE_CLOUD_private_key,
                "client_email": process.env.GOOGLE_CLOUD_client_email,
                "client_id": process.env.GOOGLE_CLOUD_client_id,
                "type": process.env.GOOGLE_CLOUD_type
            }
        });
  10. rakyll commented on Aug 26, 2014

    @rakyll
    rakyll
    on Aug 26, 2014
    Contributor
    More actions

    We can rename the key to credentials which is basically what Connection object is doing at the moment. It's reading the file from keyFilename, parse and set it to Connection.prototype.credentials.

    Btw, you only need to provide private_key and client_email.

    var gcloud = require('gcloud'),
        bucket = new gcloud.storage.Bucket({
            bucketName: YOUR_BUCKET_NAME,
            credentials: {
                "private_key": process.env.GOOGLE_CLOUD_private_key,
                "client_email": process.env.GOOGLE_CLOUD_client_email,
            }
        });
  11. hulbert commented on Aug 27, 2014

    @hulbert
    hulbert
    on Aug 27, 2014
    Author
    More actions

    @rakyll 👍 your example would address my original issue

  12. stephenplusplus
    added 3 commits that reference this issue on Aug 27, 2014

    connection: allow passing a credentials object. fixes googleapis#136.

    This issue will close once commit a553164 is merged into the 'master' branch.
    a553164

    connection: allow passing a credentials object. fixes googleapis#136.

    This issue will close once commit 4f1313c is merged into the 'master' branch.
    4f1313c

    connection: allow passing a credentials object. fixes googleapis#136.

    This issue will close once commit de4136b is merged into the 'master' branch.
    de4136b
  13. stephenplusplus
    closed this as completedin de4136bon Aug 27, 2014
  14. 70 remaining items

  15. GautamSharda
    added a commit that references this issue on Feb 3, 2026

    chore(deps): update dependency typescript to v3 (#136)

    1b20f1a
  16. sofisl
    added a commit that references this issue on Feb 4, 2026

    Release v0.9.1 (#136)

    fd4347d
  17. sofisl
    added 2 commits that reference this issue on Feb 24, 2026

    Accept strings in where(FieldPath.documentId(), ...) (#136)

    5acd689

    chore: run CI as non-root user (#136)

    31a4b12
  18. GautamSharda
    added a commit that references this issue on Feb 25, 2026

    chore: release 2.3.0 (#136)

    55342a9
  19. sofisl
    added a commit that references this issue on Feb 26, 2026

    Cleanup Spanner region tags. (#136)

    6a010f6
  20. codyoss
    added a commit that references this issue on Mar 5, 2026

    chore: release 1.0.2 (#136)

    c7748fb
  21. GautamSharda
    added a commit that references this issue on Mar 5, 2026

    fix: update linking for samples (#136)

    d25be03
  22. codyoss
    added 3 commits that reference this issue on Mar 9, 2026

    refactor!: rewrite streaming logic (#136)

    930a6f4

    refactor!: rewrite streaming logic (#136)

    66f04cf

    build: perform publish using Node 12 (#136)

    6c82ef1
  23. GautamSharda
    added 3 commits that reference this issue on Mar 12, 2026

    build: switch to GitHub app for releases (#136)

    7c31947

    build: switch to GitHub app for releases (#136)

    d1724be

    chore: release 0.18.6 (#136)

    d7e7fd9
  24. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    chore: run CI as non-root user (googleapis#136)

    e88162e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @stephenplusplus
    stephenplusplus

Labels

🚨This issue needs some love.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    • Core Stable

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.