You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cloud-functions-config

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloud-functions-config

Get per-project config for your cloud functions from a json file on GCS

0.1.0
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Cloud Functions Config from GCS

Configure your cloud functions with a per-project (per-env) secret JSON file hosted on GCS

Background

In the GCP docs it is implied that you should set up one project per environment:

We recommend that you spend some time planning your project IDs for manageability. A typical project ID naming convention might use the following pattern:

[company tag]-[group tag]-[system name]-[environment (dev, test, uat, stage, prod)]

Method

  • cloud-functions-config uses process.env.GCP_PROJECT to find out which bucket to fetch the config from.
  • once the config.json file has been fetched the JSON key-values are added to process.env under keys prefixed with cfc__).

Prerequisites

  • a GCS bucket named [project-ID]-config-private that your cloud functions has permission to read from (this should be enabled by default)
  • a file config.json stored within the above bucket

Usage

npm i cloud-functions-config
const { initConfig, getConfig } = require('cloud-functions-config')

// initConfig will only requests config from GCS if none has been set yet
initConfig()
  .then(config => {
      // app logic
      console.log(config)
      // { token: 'xxxxxx', ... } 
    })

FAQs

Package last updated on 14 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts