Ad
Setting Secret Key In Google Cloud Functions
I need to sftp into an amazon ec2 instance to send files from data farmed from a firestore data base. I'm trying to open the connection but I need to have access to the ec2 secret key file in the cloud functions.
I've done slightly similar things such as with stripe and the secret key so I believe this should be possible. How do I upload my secret key file so I can have access to in the function below?
return sftp.connect({
host: 'xxxxxxxxxxxx',
port: 'xxxx',
username: 'xxxxxx',
privatekey: 'filepath'
})
Ad
Answer
I simply put the secret key in the main directory and read it into the environment with
var privateKey = require('fs').readFileSync('./xxxxxxx.pem', {'encoding':'utf8'});
I may ask another question later to see if this is secure but I don't see why not.
Ad
source: stackoverflow.com
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error
Ad