Reputation: 11
I'm trying to set up the gcp
credentials for a Twilio Function.
Unfortunately it looks like I can only setup env
variables but not reference a json
file as we need to do it for GCP.
Did anyone manage to set up GCP credentials from a Twilio Function?
Thank you!
Upvotes: 1
Views: 144
Reputation: 10781
A Twilio Function can parse a Twilio Asset file which contains JSON, there is an example of this below.
twilio Reject Incoming Calls with a Phone Number Blacklist
const fs = require('fs');
exports.handler = function(context, event, callback) {
let fileName = 'blacklist.json';
let file = Runtime.getAssets()[fileName].path;
let text = fs.readFileSync(file);
let blacklist = JSON.parse(text);
console.log(blacklist);
...
Upvotes: 1