├── bin ├── detect └── compile ├── README.md └── LICENSE /bin/detect: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Google Cloud" 4 | exit 0 5 | -------------------------------------------------------------------------------- /bin/compile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # bin/compile 3 | 4 | BUILD_DIR=${1:-} 5 | CACHE_DIR=${2:-} 6 | ENV_DIR=${3:-} 7 | 8 | echo "------> Generating .profile.d file to generate google-credentials.json at startup" 9 | mkdir -p $BUILD_DIR/.profile.d 10 | echo "echo ${GOOGLE_CREDENTIALS@Q} > /app/google-credentials.json" > $BUILD_DIR/.profile.d/google-credentials.sh 11 | chmod +x $BUILD_DIR/.profile.d/google-credentials.sh 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # heroku-google-application-credentials-buildpack 2 | Generates a Google credential file based on Heroku Config Vars. 3 | 4 | This is useful when using a package such as [@google-cloud/storage](https://www.npmjs.com/package/@google-cloud/storage) which loads credentials from a file instead of an environmental variable. 5 | 6 | ## Usage 7 | 8 | 1. Create Config Vars key `GOOGLE_CREDENTIALS` and paste the content of service account credential JSON file as is. 9 | 2. Create a key under Config Vars `GOOGLE_APPLICATION_CREDENTIALS` and set a value as `google-credentials.json`. 10 | 11 | The script with generate a file called `google-credentials.json` which holds the key from the step #1 above. 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Elisha Terada 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------